All Syllabus

Home About Search Unit 1 Unit 2 Unit 3 Unit 4 Unit 5 Unit 6 Unit 7 Unit 8 Unit 9      

8051 Serial Communication

Power Mode control Register

Serial Data Transmission Modes

Programming the 8051 to transfer data serially

8051 Serial Communication

8051 SERIAL COMMUNICATION


Types of Serial Communication
1. Synchronous serial Data Communication
2. Asynchronous Serial Data Communication
Pins TxD (P3.1) and RxD (P3.0) are used for transmitting and receiving the data
serially. Figure below shows synchronous serial data communication which uses a
common clock for synchronization of transmitter and receiver

Serial Interface


The serial port of 8051 is full duplex, i.e., it can transmit and receive simultaneously. The
register SBUF is used to hold the data. The special function register SBUF is physically two
registers. One is, write-only and is used to hold data to be transmitted out of the 8051 via TXD.
The other is, read-only and holds the received data from external sources via RXD. Both
mutually exclusive registers have the same address 099H.

Serial Port Control Register (SCON)


Register SCON controls serial data communication.
Address: 098H (Bit addressable)

Mode select bits

SM2:used for multiprocessor communication.
REN: set or cleared by software to enable/disable reception.
TB8: Transmitted bit 8,not widely used.
RB8:Received bit 8.
TI:Transmit interrupt flag –set by the hardware at the beginning of the stop bit in


mode 1, must be cleared by software.
RI: Receive interrupt flag –set by the hardware halfway through the stop bit time in
mode1, must be cleared by software.

SCON Register


Serial control register: SCON
SM0, SM1 : Serial port mode specifier
REN : (Receive enable) set/cleared by software to enable/disable reception.
TI : Transmit interrupt flag.
RI : Receive interrupt flag.
SM2 = RB8 = TB8 =0 (not widely used)


REN (Receive Enable) -SCON.4
Set/cleared by software to enable/disable reception.
REN=1
 It enable the 8051 to receive data on the RxD pin of the 8051.
 If we want the 8051 to both transfer and receive data, REN must be set to 1.


SETB SCON.4
REN=0
The receiver is disabled.
The 8051 can not receive data.
CLR SCON.4
SM0, SM1

SM1 and SM0 determine the framing of data.
SCON.6 (SM1) and SCON.7 (SM0)
Only mode 1 is compatible with COM port of PC.

TB8 (Transfer Bit 8) -SCON.3
• TB8 is used for serial modes 2 and 3.
• The 9th bit that will be transmitted in mode 2 & 3.
• Set/Cleared by software
RB8 (Receive Bit 8) -SCON.2
In serial mode 1, RB8 gets a copy of the stop bit when an 8-bit data is received.
TI (Transmit Interrupt Flag) -SCON.1
When the 8051 finishes the transfer of the 8-bit character, it raises the TI flag.
TI is raised by hardware at the beginning of the stop bit in mode 1.
Must be cleared by software
RI (Receive Interrupt) -SCON.0
Receive interrupt flag. Set by hardware halfway through the stop bit time in mode 1.
Must be cleared by software.
When the 8051 receives data serially via RxD, it gets rid of the start and stop bits and
place the byte in the SBUF register.
Then 8051 rises RI to indicate that a byte.
RI is raised at the beginning of the stop bit.