MICROPROCESSOR
PART 15
SIBIN K
Electrical Subject Matter Expert
Serial port
● 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 register SCON controls data communication
● PCON controls data rates
● Pins RxD (P3.0) and TxD (P3.1) do the data transfer
● 8051 provides 4 programmable modes for serial data communication, mode can be
selected by setting the SM0 and SM1 bits in SCON
Serial Port Control Register (SCON)
● Register SCON controls serial data communication.
● Address: 098H (Bit addressable)
SM0 SM1 SM2 REN TB8 RB8 TI RI
● Mode select bits
SM0 SM1 Mode
0 0 Mode 0
0 1 Mode 1
1 0 Mode 2
1 1 Mode 3
● SM2: multi processor communication bit
● REN: Receive enable bit
● TB8: Transmitted bit 8 (Normally we have 0-7 bits transmitted/received)
● RB8: Received bit 8
● TI: Transmit interrupt flag
● RI: Receive interrupt flag
Power Mode control Register
SMOD --- --- --- GF1 GF2 PD IDL
● SMOD: Serial baud rate modify bit
● GF1: General purpose user flag bit 1
● GF0: General purpose user flag bit 0
● PD: Power down bit
● IDL: Idle mode bit
Mode-0:
● In this mode, the serial port works like a shift register and the data transmission works
synchronously with a clock frequency of fosc /12.
● Serial data is received and transmitted through RXD.
● 8 bits are transmitted/ received at a time.
● Pin TXD outputs the shift clock pulses of frequency fosc /12, which is connected to the
external circuitry for synchronization.
● The shift frequency or baud rate is always 1/12 of the oscillator frequency
Mode-1 (standard UART mode) :
● In mode-1, the serial port functions as a standard Universal Asynchronous Receiver
Transmitter (UART) mode.
● 10 bits are transmitted through TXD or received through RXD.
● The 10 bits consist of one start bit (which is usually '0'), 8 data bits (LSB is sent
first/received first), and a stop bit (which is usually '1').
● Once received, the stop bit goes into RB8 in the special function register SCON.
● The baud rate is variable.
Interrupts
● There are five interrupt sources for the 8051, which means they can recognize 5 different
events that can interrupt regular program execution.
● Each interrupt can be enabled or disabled by setting bits of the IE special purpose
register.
● the whole interrupt system can be disabled by clearing the EA bit of the same register
● EA – global interrupt enable/disable:
0 – disables all interrupt requests.
1 – enables all individual interrupt requests.
● ES – enables or disables serial interrupt:
0 – UART system cannot generate an interrupt.
1 – UART system enables an interrupt.
● ET1 – bit enables or disables Timer 1 interrupt:
0 – Timer 1 cannot generate an interrupt.
1 – Timer 1 enables an interrupt.
● EX1 – bit enables or disables external 1 interrupt:
0 – change of the pin INT0 logic state cannot generate an interrupt.
1 – enables an external interrupt on the pin INT0 state change.
● ET0 – bit enables or disables timer 0 interrupt:
0 – Timer 0 cannot generate an interrupt.
1 – enables timer 0 interrupt.
● EX0 – bit enables or disables external 0 interrupt:
0 – change of the INT1 pin logic state cannot generate an interrupt.
1 – enables an external interrupt on the pin INT1 state change
Interrupt Priorities
1. External interrupt INT0
2. Timer 0 interrupt
3. External Interrupt INT1
4. Timer 1 interrupt
5. Serial Communication Interrupt
PS – Serial Port Interrupt priority bit
o Priority 0
o Priority 1
PT1 – Timer 1 interrupt priority
o Priority 0
o Priority 1
PX1 – External Interrupt INT1 priority
o Priority 0
o Priority 1
PT0 – Timer 0 Interrupt Priority
o Priority 0
o Priority 1
PX0 – External Interrupt INT0 Priority
o Priority 0
o Priority 1
Interrupt Destinations
● Each interrupt source causes the program to do a hardware call to one of the dedicated
addresses in the program memory
Interrupt Address (hex)
IE0 0003
TF0 000B
IE1 0013
TF1 001B
SERIAL 0023