UART Serial communication using 8051

We have covered the basics of timers in the previous tutorial, with that we can see how can a microcontroller communicate with a computer serially.

There are two ways to connect a microcontroller to a computer.

  • Using RS232 protocol to the legacy serial port.
  • Using a USB to serial convertor.

From microcontroller programming point of view, there is fundamentally no difference.


8051 UART Registers

SBUFF: Serial buffer register

SBUFF
D7 D6 D5 D4 D3 D2 D1 D0

SCON: Serial Control Register

SCON
D7 D6 D5 D4 D3 D2 D1 D0
SM0 SM1 SM2 REN TB8 RB8 TI RI
SM0 SM1 Operation Discription Baud Rate Source
0 0 Mode 0 8bit ShiftReg 1/12 the quartz frequency
0 1 Mode 1 8 bit UART Determined by the timer 1
1 0 Mode 2 9 bit UART 1/32 the quartz frequency
1 1 Mode 0 9 bit UART Determined by the timer 1