Intel MCS 51 User Manual page 244

Table of Contents

Advertisement

87C51GB HARDWAREDESCRIPTION
8.3 AutomaticAddressRecognition
AutomaticAddress Recognitionreduces the CPU time
required to service the serial port. Since the CPU is
only interrupted when it receivesits own ad-
the
s&ware overhead to compareaddresses is eliminated.
Automatic addreasrecognitionis enabledby setting the
SM2bit in SCON.With this feature enabled in one of
the 9-bit modes, the ReceiveInterrupt (RI) flag will
only get set when the receivedbyte cm-respondsto ei-
ther a Given or Broadcastaddress.
The master can selectivelycommunicatewith groupsof
slaves by using the Given Address. Addressing all
slaves at once is possiblewith the Broadcast Address.
These addressesare definedfor each slave by two Spe-
cial Function Registers:SADDR and SADEN.
A slave's individual addreas is specified in SADDR.
SADENis a maskbyte that definesdon't-caresto form
the Given Address. These don't-careaallow flexibility
in the user-defined protocol to address one or more
slavesat a time. The followingis an exampleof howthe
user could define Given Addresses to selectivelyad-
dreas different slavea.
Slave 1:
SADDR=
1111 0001
SADEN=
1111 lOlO
GIVEN=
1111 oxox
Slave 2:
SADDR=
1111 0011
SADEN=
1111 1001
GIVEN=
1111 Oxxl
TheSADENbyteaare selectedsuch that each slavecan
be addressed separately. Notice that bit 1 (LSB) is a
don't-carefor Slave 1'sGivenAddreas, but bit 1 = 1
for Slave2. Thus, to selectivelycommunicatewithjust
Slave1the master must sendan address with bit 1 = O
(e.g. 11110000).Similarly,bit 2 = Ofor Slave 1,but is
a don't-carefor Slave2. Nowto cmnmunicatewithjust
Slave2 an address with bit 2 = 1 must be used (e.g.
11110111).Finally, for a master to eornm unicate with
both slavesat oncethe addreasmust havebit 1 = 1and
bit
2 = O.
Notice,
however, that bit
3 is
a don't-care for both
slaves.
This allows
two
Merent
addreases to select
both slaves (11110001 or 11110101). If a third slave
was added that required its bit 3 = O,then the latter
addreasmuld be used to communicatewith Slave1and
2 but not Slave3.
The master can also communicate with all slavea at
oncewith the BroadcastAddress.It is formedfrom the
logicalOR of the SADDR and SADEN registers with
zeros definedas don't-cares.The don't-caresalso allow
flexibility in defining the Broadcast Address, but in
most applicationsa BroadcastAddresswill be OFFH.
The feature works the same way in the 8-bit mode
(Mode 1)as in the 9-bitmodes,exceptthat the stop bit
takes the place of the 9th data bit. If SM2is set, the RI
flagis set onlyif the receivedbyte matchesthe Givenor
Broadcast Addreas and is termma
" ted by a valid stop
bit. Settingthe SM2bit has no &Teet i n Mode O.
On reset, the SADDRand SADENregistersare initial-
ized to OOH,which defies the Given and Broadcast
Addressesas XXXX =
(~ don't-cares).'fhiSas-
sures the 8XC51GBserial port to be backwardscom-
patibility with other MCS-51products which do not
implementAutomaticAddressing.
8.4 BaudRates
The baud rate in ModeOis freed:
Mode OBaudRate =
OscillatorFrequency
12
The baud rate in Mode 2 dependson the value of bit
SMOD1 in Special Function Register PCON. If
SMOD1 = O(which is the value on reset), the baud
rate is 1/64 the oscillatorr%quency.If SMOD1 = 1,
the baud rate is 1/32 the oscillatorfrequency.
Mode2
BaudRate = 2 SMOD1 x
OscillatorFrequency
e4
The baud rates in Mode 1 and Mode 3 are determined
by the Timer 1 overflowrate, or by Timer 2 overtlow
rate, or by both (one for transmit and the other for
receive).
8.5 Timer 1 to GenerateBaudRates
When
T imer 1 is used as the baud rate generator, the
baud ratea in Mcdes 1 and 3 are determined by the
Timer 1 overtlowrate and the value of SMOD1as fol-
lows:
#a~;&&md 3 = 2
SMOD1 X
Timer 1 OverflowRate
32
Figure 28 showshow commonlyused Baud Rates may
be generated.The Timer 1 interrupt shouldbe disabled
in this application.Timer 1can be configuredfor either
"timer" or "counter" operation, and in any of its 3
running modes. In most applications,it is configured
for "timer" operation in the auto-reload mode (high
6-36

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents