Serial Communication 8051 - Theory.
                     Types of serial communication : UART  - I2C - SPI
                    We would be using UART for serial communication.
Registers required for UART : SBUF - SCON - TMOD
SCON register :
                     | SM0 | SM1 | SM2 | REN | TB8 | RB8 | TI | RI | 
SM0   SM1  
 0         0         -    Mode 0 ( Shift register mode )
 0         1         -    Mode 1  ( 8 bit UART - Timer defined baud rate ).
 1         0         -    Mode 2  ( 9 bit UART )
1         1         -    Mode 3  ( 9 bit UART )
SM2 - Multiprocessing.
REN - Receiving Enabled ( 1 )
           Receiving Disabled ( 0 )
TI    -  Transmit interrupt flag.
RI   -   Receive interrupt flag.
We have set SCON = 0x5D; for mode 1 configuration.
TMOD register :
Timer 1 in mode 2 : TMOD = 0X20;
Now TH register needs to be fixed for baud rate.
Crystal oscillator freq --> 11.0592Mhz.
Machine Cycle            --> 12
Crystal oscillator / Machine Cycle = 921.6 Khz.
UART block  --> 32
921.6 / 32 = 28800 Hz
but required baud rate is 9600. 
  28800 / 9600 = 3 
Maximum value of TH is FF
If you want to set baud rate to 9600 . so (FF + 1) - 3  = FD 
therefore  TH = 0XFD ; (for baud rate requirement of 9600 )  
Comments
Post a Comment