Professional Documents
Culture Documents
51 UART Mail
51 UART Mail
•
SCON (serial control) register
The SCON register is an 8-bit register used to program the start bit,
stop bit, and data bits of data framing, among other things.
• SMO and SMI are D7 and D6 of the SCON register, respectively.
These two bits determine the framing of data by specifying the number
of bits per character, and the start and stop bits.
• SM2 is the D5 bit of the SCON register. This bit enables the
multiprocessing capability of the 8051 and is beyond the discussion of
this chapter. For our applications, we will make SM2 = 0 since we are
not using the 8051 in a multiprocessor environment
• When the 8051 receives data serially via RxD, it gets rid of the
start and stop bits and places the byte in the SBUF register. Then
it raises the RI flag bit to indicate that a byte has been received
and should be picked up before it is lost. RI is raised halfway
through the stop bit.
SBUF register
• SBUF is an 8-bit register used solely for serial communication in the 8051.
For a byte of data to be transferred via the TxD line, it must be placed in the
SBUF register. The moment a byte is written into SBUF, it is framed with the start
and stop bits and transferred serially via the TxD pin.
• Similarly, when the bits are received serially via RxD, the 8051 deframes it by
eliminating the stop and start bits, making a byte out of the data received, and then
placing it in the SBUF.
• RECEIVE - Data receive through the RXD pin starts upon the two
following conditions are met: bit REN=1 and RI=0 (both of them are
stored in the SCON register). When all 8 bits have been received,
the RI bit of the SCON register is automatically set indicating that
one byte receive is complete.
Mode 1
• In mode 1, 10 bits are transmitted through the TXD pin or received
through the RXD pin in the following manner: a START bit (always 0),
8 data bits (LSB first) and a STOP bit (always 1). The START bit is
only used to initiate data receive, while the STOP bit is automatically
written to the RB8 bit of the SCON register.
• RECEIVE - The START bit (logic zero (0)) on the RXD pin initiates
data receive. The following two conditions must be met: bit REN=1 and
bit RI=0. Both of them are stored in the SCON register. The RI bit is
automatically set upon data reception is complete.
Mode 2
• In mode 2, 11 bits are transmitted through the TXD pin or received
through the RXD pin: a START bit (always 0), 8 data bits (LSB first), a
programmable 9th data bit and a STOP bit (always 1). On transmit, the
9th data bit is actually the TB8 bit of the SCON register. This bit usually
has a function of parity bit. On receive, the 9th data bit goes into the
RB8 bit of the same register (SCON).The baud rate is either 1/32 or
1/64 the oscillator frequency.
• When the 8051 is powered up, D7 (SMOD bit) of the PCON register is
zero. We can set it to high by software and thereby double the baud
rate.
•
Power control register (PCON)
power-saving modes of operation: Idle and Power Down.
• In some cases CPU has to wait for external signal for its operation. Even CPU is
inactive it consumes power from battery. To reduce power consumption of CPU
it should be operated in sleep mode.
• Idle mode
• Upon the IDL bit of the PCON register is set, the microcontroller turns off the
greatest power consumer- CPU unit while peripheral units such as serial port,
timers and interrupt system continue operating normally consuming 6.5mA. In
Idle mode, the state of all registers and I/O ports remains unchanged.
• While the microcontroller is in Power Down mode, the state of all SFR registers
and I/O ports remains unchanged. By setting it back into the normal mode, the
contents of the SFR register is lost, but the content of internal RAM is saved.
Power Consumption Control