COI1 Serial Communication in 8051

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Microprocessors and Microcontrollers – 11EC311

Serial Communication in 8051


Introduction

22/09/15 8051 Serial Communication - Copyleft


Data Trasmission Mechanisms

22/09/15 8051 Serial Communication - Copyleft


Serial Communication

● Synchronous – Block at a Time


● Asynchronous – Byte at a Time
● Baud Rate - Data Transfer Rate – bps (bits per second)

22/09/15 8051 Serial Communication - Copyleft


RS232 Standard

22/09/15 8051 Serial Communication - Copyleft


8051 UART

● Universal Asynchronous Receiver Transmitter


● UART Divides Machine Cycle Frequency by 32 for Baud
● Timer 1 in Mode 2(Auto Reload) for generating Baud Rate

22/09/15 8051 Serial Communication - Copyleft


SBUF Register

● Serial Buffer
● 8-bit Register
● Transmission of Data
–Load value into SBUF Register
– Framed and Sent via TxD Line (P3.1)
● Reception of Data
– Serially recived data via RxD Line(P3.0)
– Deframed and placed in SBUF

22/09/15 8051 Serial Communication - Copyleft


SCON(Serial Control) Register

22/09/15 8051 Serial Communication - Copyleft


SCON Register

● T8 - 9th Bit to Transmit in Mode 2,3


● R8 - 9th Bit Received in Mode 2,3
● Mode 1 – 8 Bit UART, 1 Start Bit , 1 Stop Bit

22/09/15 8051 Serial Communication - Copyleft


Programming 8051 for Serial Transmit

● Load TMOD – Timer 1 Auto Reload Mode


● Load TH1 with Value for Necessary Baud Rate
● Load SCON
● Run Timer 1 to Generate Baud
● Load byte of data into SBUF
● Monitor TI to see if transfer is complete then clear TI
● Transfer Next Byte by repeating above two steps

22/09/15 8051 Serial Communication - Copyleft


Example: Serial Transfer of Character “M”

MOV TMOD,#20H
MOV TH1,#-3
MOV SCON,#50H
SETB TR1
MOV SBUF,#”M”
JNB TI,$
CLR TI
END

22/09/15 8051 Serial Communication - Copyleft


Programming 8051 to Receive Serially

● Load TMOD – Timer 1 Auto Reload Mode


● Load TH1 with Value for Necessary Baud Rate
● Load SCON
● Run Timer 1 to Generate Baud
● Monitor RI to see if any character received, then clear RI
● When RI = 1, Copy the Received byte available in SBUF
● Repeat above two steps to receive continuously

22/09/15 8051 Serial Communication - Copyleft


Example: Receiving Serially and send to P1

MOV TMOD,#20H
MOV TH1,#-3
MOV SCON,#50H
CLR TR1
JNB RI,$
MOV A,SBUF
MOV P1,A
END

22/09/15 8051 Serial Communication - Copyleft


PCON Register

22/09/15 8051 Serial Communication - Copyleft


Problems for LTC – Serial Communication

● Transmit “Technology to the Society” Serially at 4800Baud

● Transmit “C” , “S” , “E” with a delay of 1 Second(Use Timers)

● Receive 10 Characters Serially and Store the data in


consecutive RAM Locations from 50H

● Transmit the above Received Data at 9600 Baud Rate

● Receive Data Continuously and Transmit Back the same


22/09/15 8051 Serial Communication - Copyleft
References

● https://www.sites.google.com/site/sripathroykoganti/my-forms

● The 8051 Microcontroller, 3rd Edition, Ayala, CENGAGE


Learning
● Microcontrollers[Theory and Applications], Ajay V
Deshmukh, Tata McGraw Hill
● The 8051 Microcontroller and Embedded Systems,
Muhammad Ali Mazidi, Pearson Education

22/09/15 8051 Serial Communication - Copyleft


Thank You

22/09/15 8051 Serial Communication - Copyleft

You might also like