Line 37: Line 37:
 
{| class="wikitable" style="text-align:center;background-color:#87A96B;margin: 1em auto 1em auto;"
 
{| class="wikitable" style="text-align:center;background-color:#87A96B;margin: 1em auto 1em auto;"
 
|-
 
|-
!SM0||SM1||Operation||Discription||Baud Rate Source
+
!SM0||SM1||Operation||Description||Baud Rate Source
 
|-
 
|-
 
|0||0||Mode 0|| 8bit ShiftReg||1/12 the quartz frequency
 
|0||0||Mode 0|| 8bit ShiftReg||1/12 the quartz frequency

Revision as of 13:15, 27 December 2013

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 Description 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