SlideShare a Scribd company logo
1 of 28
Download to read offline
ECE473/573
Microprocessor System Design, Dr. Shiue
1
8051 Serial Communications
ECE473/573
Microprocessor System Design, Dr. Shiue
2
Parallel vs. Serial
• Parallel Communication (Printer)
– Fast, but distance cannot be great.
– Expensive
• Serial Communication (Telephone line)
– Long distance
– cheaper
Sender Receiver
Sender
City A
Receiver
City B
One bit/data line
One byte at a time or more
ECE473/573
Microprocessor System Design, Dr. Shiue
3
Serial Communications
• Serial Communication (Telephone line)
• P/S: Parallel-in-Serial-out Shift Register
• S/P: Serial-in-Parallel-out Shift Register
• D/A: Digital-Analog Converter
• A/D: Analog-Digital Converter
Sender
City A
Receiver
City BP/S D/AD/A A/D D/AS/P
ECE473/573
Microprocessor System Design, Dr. Shiue
4
Asynchronous vs. Synchronous
• Two methods of Serial Communication
– Synchronous: Transfer block of data (characters) at a time.
– Asynchronous: Transfer a single byte at a time.
• You could write S/W to use either of these methods, but
the programs can be tedious and long. So, H/W is
developed instead.
• This H/W is called UART or USART
• UART: Universal Asynchronous Receiver-Transmitter
• USART: Universal Synchronous-Asynchronous Receiver-
Transmitter
• The 8051 chip has a built-in UART.
ECE473/573
Microprocessor System Design, Dr. Shiue
5
Duplex vs. Simplex
• Duplex
• Simplex (only transmit)
PC Printer
PC PCTx and Rx
Only Tx
ECE473/573
Microprocessor System Design, Dr. Shiue
6
Duplex
• Full Duplex: Data is transmitted both way at the same
time.
• Half Duplex: Data is transmitted one way at a time.
Tx Rx
Rx Tx
Need 2 lines
Tx Rx
Rx Tx
Need 1 lines
ECE473/573
Microprocessor System Design, Dr. Shiue
7
Asynchronous Communications
• Asynchronous serial communication is widely used for
character-oriented (1 byte) transmissions.
– Synchronous serial communication is widely used for block-
oriented (multiple bytes) transmissions.
• Start and stop bits
STOP
bit
START
bit
ASCII Character
D7 D6 D5 D4 D3 D2 D1 D0 mark
space
Only one bit ‘0’
Go out first!
One or two bits ‘1’
Go out last!
Framing
ECE473/573
Microprocessor System Design, Dr. Shiue
8
Asynchronous
• New System: ASCII character A (0100 0001B) 8-bit
– When there is no transfer, mark is ‘1’ and space is ‘0’.
• Older System: ASCII is 7-bit
– Due to the slowness of receiving mechanical devices, 2 stop bits
were used to give the device sufficient time to organize itself.
Mark
=1
0100000101Space
=0
7-bit ASCII Character 12
Stop bits Start bit
ECE473/573
Microprocessor System Design, Dr. Shiue
9
Parity Bit
• Even-Parity bit system
– 01001011 # of ‘1’=4 P=0
• Odd-Parity bit system
– 01001011 # of ‘1’=4 P=1
• UART chips allow programming of the parity bit for odd-,
even-, and no-parity options.
ECE473/573
Microprocessor System Design, Dr. Shiue
10
Data Transfer Rate
• Data Transfer Rate
– Bits per second (bps) is also called Baud rate (the number of
signals changes per second)
– IBM PC/XT 100 ~ 9600 bps
– Pentium PC 56k bps (recent MODEM)
• Asynchronous data communication, the baud rate is
limited to 100,000 bps.
• Interfacing standard: RS232
ECE473/573
Microprocessor System Design, Dr. Shiue
11
RS232
• PC: COM1 (Mouse), COM2: (MODEM & RS232)
• RS232 is set by Electronics Industries Association (EIA) in
1960.
• 1963: RS232A
• 1965: RS232B
• 1969: RS232C
• RS232 is a serial I/O interfacing standard; however, since
the standard was set long before the advent of the TTL
logic family, its input and output voltage levels are not
TTL compatible.
• TTL is Transistor-Transistor Logic family (Bipolar
transistor) in 1968
ECE473/573
Microprocessor System Design, Dr. Shiue
12
Line Driver: MAX232
• RS232 is not compatible to TTL. For this reason, to
connect any RS232 to a microcontroller system, we must
use “Voltage Converters” such as MAX232 to convert the
TTL logic levels to the RS232 voltage levels, and vice
versa.
• MAX232 IC chips is referred to as “Line Driver”.
ECE473/573
Microprocessor System Design, Dr. Shiue
13
RS232 Connector: DB-25
• DB-25 Connector
– DB-25P (Plug)
– DB-25S (Socket)
• DTE: Data Terminal Equipment: RS232
• DCE: Data Communication Equipment: MODEM
1 13
14 25
Pin 1: Ground
Pin 2: TxD
Pin 3: RxD
:
ECE473/573
Microprocessor System Design, Dr. Shiue
14
RS232 Connector: DB-9
• DB-9 Connector
1 5
6 9
Ring IndicatorRI9
Clear To Send!CTS8
Request To Send!RTS7
Data Set Ready!DSR6
GroundGND5
Data Terminal ReadyDTR4
TransmitTxD3
ReceiveRxD2
Data Carrier Detect!DCD1
descriptionfunctionPin
ECE473/573
Microprocessor System Design, Dr. Shiue
15
8051 Connection to RS232
• Since RS232 standard is not TTL compatible, so we need
MAX232 (line driver)
8051
MAX232 DB-9 (RS232 Connector)
TxD
RxD
11 (P3.1)
10 (P3.0)
11 T1 in T1 out 14 2 RxD
12 R1 out R1 in 13 3 TxD
GND
5
ECE473/573
Microprocessor System Design, Dr. Shiue
16
Baud Rate
• Q1: With XTAL=11.0592MHz, find the TH1 value needed
to have the following baud rate: (a) 9600, (b) 2400, and (c)
1200.
ECE473/573
Microprocessor System Design, Dr. Shiue
17
SBUF Register
• SBUF Register: For a byte of data to be transferred via the
TxD line, it must be placed in the SBUF.
• SBUF holds the byte of data when it is received by the
8051’s RxD line.
8051
MAX232 DB-9 (RS232 Connector)
TxD
RxD
11 (P3.1)
10 (P3.0)
11 T1 in T1 out 14 2 RxD
12 R1 out R1 in 13 3 TxD
GND
5
Framed
Deframed
SBUF
ECE473/573
Microprocessor System Design, Dr. Shiue
18
SCON Register
RITIRB8TB8RENSM2SM1SM0 SCON
31 1
21 0
8 bit data, 1 stop bit , 1 start bit10 1
00 0
ModeSM0 SM1
• Mode 0, 2, and 3 are ready used today.
• Mode 1 is compatible with the COM port of IBM PC.
• Mode 1 allows the baud rate to be variable and is set by
Timer 1 of 8051.
ECE473/573
Microprocessor System Design, Dr. Shiue
19
SCON Register
• SM2 enable the multiprocessing capability of the 8051.
Here we make SM2=0.
• REN: Receive Enable
– REN=1: it allows the 8051 to receive data on the RxD pin. If you
want the 8051 to both transfer and receive data, REN must be set
to ‘1’. SETB SCON.4
– REN=0: make the receiver is disabled.
• TB8: Transfer bit 8
– Is used for serial modes 2 and 3, so here we make TB8=0.
D0D1D2D3D4D5D6D7Stop
Bit
1 byte of data
Bit 8
ECE473/573
Microprocessor System Design, Dr. Shiue
20
SCON Register
• RB8: Receive bit 8
– Is used for serial modes 2 and 3, so here we make RB8=0.
• TI: Transmit Interrupt (this is a flag bit)
– When 8051 finish the transfer of the 8-bit character, it raises the TI
flag to indicate that it is ready to transfer another byte.
• RI: Receive Interrupt
– When 8051 receive data via RxD, it get rid of the start and stop
bits (deframed procedure) and places the byte in the SBUF.
– Then it raises the RI flag to indicate that a byte has been received
and should be picked up before it is lost.
ECE473/573
Microprocessor System Design, Dr. Shiue
21
Programming (Transfer)
1. MOV TMOD, #20H ; Timer 1, mode 2
2. TH1 is loaded to set the baud rate.
3. MOV SCON, #50H
4. SETB TR1 ; Run Timer 1
5. MOV SBUF, #’D’
6. Loop: JNB TI, Loop ; Monitor TI
7. CLR TI
8. Repeat step 5 for next character.
RI
0
TI
0
RB8
0
TB8
0
REN
1
SM2
0
SM1
1
SM0
0
SCON
REN=1: allows TxD and RxD
ECE473/573
Microprocessor System Design, Dr. Shiue
22
Examples
• Q2: Write a program for the 8051 to transfer letter ‘A’
serially at 4800 baud rate, continuously.
• Q3: Write a program to transfer the message “Yes” serially
at 9600 baud, do this continuously.
ECE473/573
Microprocessor System Design, Dr. Shiue
23
Programming (Receive)
1. MOV TMOD, #20H ; Timer 1, mode 2
2. TH1 is loaded to set the baud rate.
3. MOV SCON, #50H
4. SETB TR1 ; Run Timer 1
5. Loop: JNB RI, Loop ; Monitor RI
6. MOV A, SBUF
7. CLR RI
8. Repeat step 5 for next character.
RI
0
TI
0
RB8
0
TB8
0
REN
1
SM2
0
SM1
1
SM0
0
SCON
REN=1: allows TxD and RxD
ECE473/573
Microprocessor System Design, Dr. Shiue
24
Examples
• Q4: Program the 8051 to receive bytes of data serially, and
put them in P1. Set the baud rate at 4800.
• Q5: Write a program to (a) send to the PC the message
“We Are Ready”, (b) receive any data sent by the PC and
put it ob LEDs connected to P1, and (c) get data on
switches and sent it to PC. The program should perform
part (a) once, but parts (b) and (c) continuously. Use the
4800 baud rate.
ECE473/573
Microprocessor System Design, Dr. Shiue
25
Doubling the Baud Rate
• Method 1: Use a high XTAL
– This method is infeasible since XTAL is fixed.
– If you change XTAL, and then it is not compatible to PC.
• Method 2: Change a bit in the PCON register
• When 8051 is powered up, D7 of PCON =0, we could set D7 of PCON
‘1’ to double the baud rate.
• Note that PCON is not bit addressible, so we need to do the following
MOV A, PCON
SETB ACC.7
MOV PCON, A
IDLPDGF0GF1---SMOD
PCON
Serial Mode Bit
ECE473/573
Microprocessor System Design, Dr. Shiue
26
Baud Rate for SMOD
• Baud rate for SMOD = ‘0’
11.0592MHz/12 = 921.6KHz
921.6KHz/32 = 28800Hz
• Baud rate for SMOD = ‘1’
11.0592MHz/12 = 921.6KHz
921.6KHz/16 = 57600Hz
ECE473/573
Microprocessor System Design, Dr. Shiue
27
Baud Rate for SMOD
E8-2424001200
F4-1248002400
FA-696004800
FD-3192009600
TH1 (Hex)TH1 (decimal)Baud Rate for
SMOD=1
(Doubling the
Baud Rate)
Baud Rate for
SMOD=0
ECE473/573
Microprocessor System Design, Dr. Shiue
28
Examples
• Q6: Assume XTAL=11.0592MHz, for the following
program, state (a) what this program does (b) compute the
frequency used by timer 1 to set the baud rate, and (c) find
the baud rate of the data transfer.
• Q7: Find the TH1 value (in both decimal and hex) to set
the baud rate to each of the following (a) 9600, and (b)
4800 if SMOD=‘1’. Assume XTAL=11.0592MHz.
• Q8: Find the baud rate if TH1 =-2, SMOD =1,
XTAL=11.0592MHz. Is this baud rate supported by IBM
PC

More Related Content

What's hot

SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2KanchanPatil34
 
Seminar on serial communication
Seminar on serial communicationSeminar on serial communication
Seminar on serial communicationSamarth Patel
 
Serial Communication Part-16
Serial Communication Part-16Serial Communication Part-16
Serial Communication Part-16Techvilla
 
8051 serial communication
8051 serial communication8051 serial communication
8051 serial communicationasteriskbimal
 
ASTROSAT SSR - 2015-05-15
ASTROSAT SSR - 2015-05-15ASTROSAT SSR - 2015-05-15
ASTROSAT SSR - 2015-05-15Aritra Sarkar
 
Fun and Easy UART - How the UART Protocol Works
Fun and Easy UART - How the UART Protocol WorksFun and Easy UART - How the UART Protocol Works
Fun and Easy UART - How the UART Protocol WorksRitesh Kanjee
 
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C ProtocolInterfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C ProtocolIJERA Editor
 
I2C programming with C and Arduino
I2C programming with C and ArduinoI2C programming with C and Arduino
I2C programming with C and Arduinosato262
 
Universal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD CoverterUniversal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD CoverterTejas Shetye
 
FPGA IMPLIMENTATION OF UART CONTTROLLER
FPGA IMPLIMENTATION OF UART CONTTROLLERFPGA IMPLIMENTATION OF UART CONTTROLLER
FPGA IMPLIMENTATION OF UART CONTTROLLERVarun Kambrath
 
I2C Bus 11.3.2 Unit 2 Design of Embedded systems Ref. Book Ajay Deshmukh
I2C Bus 11.3.2 Unit 2 Design of Embedded systems  Ref. Book Ajay DeshmukhI2C Bus 11.3.2 Unit 2 Design of Embedded systems  Ref. Book Ajay Deshmukh
I2C Bus 11.3.2 Unit 2 Design of Embedded systems Ref. Book Ajay DeshmukhTejas Shetye
 
Serial communication in LPC2148
Serial communication in LPC2148Serial communication in LPC2148
Serial communication in LPC2148sravannunna24
 
Verification of uart ip core using uvm
Verification of uart ip core using uvmVerification of uart ip core using uvm
Verification of uart ip core using uvmeSAT Publishing House
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral InterfaceAnurag Tomar
 
Lecture 10 (serial communication)
Lecture 10 (serial communication)Lecture 10 (serial communication)
Lecture 10 (serial communication)cairo university
 

What's hot (20)

SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
 
Seminar on serial communication
Seminar on serial communicationSeminar on serial communication
Seminar on serial communication
 
8051 serial communication-UART
8051 serial communication-UART8051 serial communication-UART
8051 serial communication-UART
 
Serial Communication Part-16
Serial Communication Part-16Serial Communication Part-16
Serial Communication Part-16
 
12 mt06ped019
12 mt06ped019 12 mt06ped019
12 mt06ped019
 
8051 serial communication
8051 serial communication8051 serial communication
8051 serial communication
 
UART
UARTUART
UART
 
ASTROSAT SSR - 2015-05-15
ASTROSAT SSR - 2015-05-15ASTROSAT SSR - 2015-05-15
ASTROSAT SSR - 2015-05-15
 
Fun and Easy UART - How the UART Protocol Works
Fun and Easy UART - How the UART Protocol WorksFun and Easy UART - How the UART Protocol Works
Fun and Easy UART - How the UART Protocol Works
 
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C ProtocolInterfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
 
I2C programming with C and Arduino
I2C programming with C and ArduinoI2C programming with C and Arduino
I2C programming with C and Arduino
 
Universal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD CoverterUniversal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
 
FPGA IMPLIMENTATION OF UART CONTTROLLER
FPGA IMPLIMENTATION OF UART CONTTROLLERFPGA IMPLIMENTATION OF UART CONTTROLLER
FPGA IMPLIMENTATION OF UART CONTTROLLER
 
Uart
UartUart
Uart
 
I2C Bus 11.3.2 Unit 2 Design of Embedded systems Ref. Book Ajay Deshmukh
I2C Bus 11.3.2 Unit 2 Design of Embedded systems  Ref. Book Ajay DeshmukhI2C Bus 11.3.2 Unit 2 Design of Embedded systems  Ref. Book Ajay Deshmukh
I2C Bus 11.3.2 Unit 2 Design of Embedded systems Ref. Book Ajay Deshmukh
 
SPI Bus Protocol
SPI Bus ProtocolSPI Bus Protocol
SPI Bus Protocol
 
Serial communication in LPC2148
Serial communication in LPC2148Serial communication in LPC2148
Serial communication in LPC2148
 
Verification of uart ip core using uvm
Verification of uart ip core using uvmVerification of uart ip core using uvm
Verification of uart ip core using uvm
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
 
Lecture 10 (serial communication)
Lecture 10 (serial communication)Lecture 10 (serial communication)
Lecture 10 (serial communication)
 

Viewers also liked

8051 microcontroller features
8051 microcontroller features8051 microcontroller features
8051 microcontroller featuresTech_MX
 
The 8051 assembly language
The 8051 assembly languageThe 8051 assembly language
The 8051 assembly languagehemant meena
 
1347 Assembly Language Programming Of 8051
1347 Assembly Language Programming Of 80511347 Assembly Language Programming Of 8051
1347 Assembly Language Programming Of 8051techbed
 
Wireless transmission of voice signal using nRF24L01 module
Wireless transmission of voice signal using nRF24L01 moduleWireless transmission of voice signal using nRF24L01 module
Wireless transmission of voice signal using nRF24L01 moduleSunil Kumar Shesma
 
Communication systems Projects for Final Year Students
Communication systems Projects for Final Year StudentsCommunication systems Projects for Final Year Students
Communication systems Projects for Final Year StudentsManoj Subramanian
 
8051 addressing modes
 8051 addressing modes 8051 addressing modes
8051 addressing modesghoshshweta
 
8051 Assembly Language Programming
8051 Assembly Language Programming8051 Assembly Language Programming
8051 Assembly Language ProgrammingRavikumar Tiwari
 
8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay Kumar8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay KumarVijay Kumar
 
Addressing mode of 8051
Addressing mode of 8051Addressing mode of 8051
Addressing mode of 8051Nitin Ahire
 
8051 architecture
8051 architecture8051 architecture
8051 architecturesb108ec
 
Question paper with solution the 8051 microcontroller based embedded systems...
Question paper with solution  the 8051 microcontroller based embedded systems...Question paper with solution  the 8051 microcontroller based embedded systems...
Question paper with solution the 8051 microcontroller based embedded systems...manishpatel_79
 
Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))Ganesh Ram
 
Green house effect
Green house effectGreen house effect
Green house effectRishabh Sood
 

Viewers also liked (20)

8051 microcontroller features
8051 microcontroller features8051 microcontroller features
8051 microcontroller features
 
8051 MICROCONTROLLER
8051 MICROCONTROLLER 8051 MICROCONTROLLER
8051 MICROCONTROLLER
 
The 8051 assembly language
The 8051 assembly languageThe 8051 assembly language
The 8051 assembly language
 
1347 Assembly Language Programming Of 8051
1347 Assembly Language Programming Of 80511347 Assembly Language Programming Of 8051
1347 Assembly Language Programming Of 8051
 
MPU-6050_RF24L01
MPU-6050_RF24L01MPU-6050_RF24L01
MPU-6050_RF24L01
 
Wireless transmission of voice signal using nRF24L01 module
Wireless transmission of voice signal using nRF24L01 moduleWireless transmission of voice signal using nRF24L01 module
Wireless transmission of voice signal using nRF24L01 module
 
Communication systems Projects for Final Year Students
Communication systems Projects for Final Year StudentsCommunication systems Projects for Final Year Students
Communication systems Projects for Final Year Students
 
8051 addressing modes
 8051 addressing modes 8051 addressing modes
8051 addressing modes
 
I o ports.ppt
I o ports.pptI o ports.ppt
I o ports.ppt
 
Class8
Class8Class8
Class8
 
8051 Assembly Language Programming
8051 Assembly Language Programming8051 Assembly Language Programming
8051 Assembly Language Programming
 
8051 Inturrpt
8051 Inturrpt8051 Inturrpt
8051 Inturrpt
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontroller
 
8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay Kumar8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay Kumar
 
Addressing mode of 8051
Addressing mode of 8051Addressing mode of 8051
Addressing mode of 8051
 
8051 architecture
8051 architecture8051 architecture
8051 architecture
 
Question paper with solution the 8051 microcontroller based embedded systems...
Question paper with solution  the 8051 microcontroller based embedded systems...Question paper with solution  the 8051 microcontroller based embedded systems...
Question paper with solution the 8051 microcontroller based embedded systems...
 
8051 Presentation
8051 Presentation8051 Presentation
8051 Presentation
 
Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))
 
Green house effect
Green house effectGreen house effect
Green house effect
 

Similar to 8051 serial communication

Similar to 8051 serial communication (20)

8051 serial communication
8051 serial communication8051 serial communication
8051 serial communication
 
The presentation is about USART and serial communication
The presentation is about USART and serial communicationThe presentation is about USART and serial communication
The presentation is about USART and serial communication
 
Sereial com. ppt
Sereial com. pptSereial com. ppt
Sereial com. ppt
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and Robotics
 
Product catlog
Product catlogProduct catlog
Product catlog
 
CC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver ModuleCC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver Module
 
Wds
WdsWds
Wds
 
7 serial port
7 serial port7 serial port
7 serial port
 
Usart 8251
Usart 8251Usart 8251
Usart 8251
 
Lab3
Lab3Lab3
Lab3
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
project 3 full report
project 3 full reportproject 3 full report
project 3 full report
 
Digital logic-formula-notes-final-1
Digital logic-formula-notes-final-1Digital logic-formula-notes-final-1
Digital logic-formula-notes-final-1
 
Analog to Digital Converter
Analog to Digital ConverterAnalog to Digital Converter
Analog to Digital Converter
 
8251 USART.pptx
8251 USART.pptx8251 USART.pptx
8251 USART.pptx
 
8251 USART
8251 USART8251 USART
8251 USART
 
microcontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdfmicrocontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdf
 
8251 a basic
8251 a basic8251 a basic
8251 a basic
 
Industrial training report of embedded system and robotics
Industrial training report of embedded system and roboticsIndustrial training report of embedded system and robotics
Industrial training report of embedded system and robotics
 
ijseas20150367
ijseas20150367ijseas20150367
ijseas20150367
 

Recently uploaded

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Recently uploaded (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

8051 serial communication

  • 1. ECE473/573 Microprocessor System Design, Dr. Shiue 1 8051 Serial Communications
  • 2. ECE473/573 Microprocessor System Design, Dr. Shiue 2 Parallel vs. Serial • Parallel Communication (Printer) – Fast, but distance cannot be great. – Expensive • Serial Communication (Telephone line) – Long distance – cheaper Sender Receiver Sender City A Receiver City B One bit/data line One byte at a time or more
  • 3. ECE473/573 Microprocessor System Design, Dr. Shiue 3 Serial Communications • Serial Communication (Telephone line) • P/S: Parallel-in-Serial-out Shift Register • S/P: Serial-in-Parallel-out Shift Register • D/A: Digital-Analog Converter • A/D: Analog-Digital Converter Sender City A Receiver City BP/S D/AD/A A/D D/AS/P
  • 4. ECE473/573 Microprocessor System Design, Dr. Shiue 4 Asynchronous vs. Synchronous • Two methods of Serial Communication – Synchronous: Transfer block of data (characters) at a time. – Asynchronous: Transfer a single byte at a time. • You could write S/W to use either of these methods, but the programs can be tedious and long. So, H/W is developed instead. • This H/W is called UART or USART • UART: Universal Asynchronous Receiver-Transmitter • USART: Universal Synchronous-Asynchronous Receiver- Transmitter • The 8051 chip has a built-in UART.
  • 5. ECE473/573 Microprocessor System Design, Dr. Shiue 5 Duplex vs. Simplex • Duplex • Simplex (only transmit) PC Printer PC PCTx and Rx Only Tx
  • 6. ECE473/573 Microprocessor System Design, Dr. Shiue 6 Duplex • Full Duplex: Data is transmitted both way at the same time. • Half Duplex: Data is transmitted one way at a time. Tx Rx Rx Tx Need 2 lines Tx Rx Rx Tx Need 1 lines
  • 7. ECE473/573 Microprocessor System Design, Dr. Shiue 7 Asynchronous Communications • Asynchronous serial communication is widely used for character-oriented (1 byte) transmissions. – Synchronous serial communication is widely used for block- oriented (multiple bytes) transmissions. • Start and stop bits STOP bit START bit ASCII Character D7 D6 D5 D4 D3 D2 D1 D0 mark space Only one bit ‘0’ Go out first! One or two bits ‘1’ Go out last! Framing
  • 8. ECE473/573 Microprocessor System Design, Dr. Shiue 8 Asynchronous • New System: ASCII character A (0100 0001B) 8-bit – When there is no transfer, mark is ‘1’ and space is ‘0’. • Older System: ASCII is 7-bit – Due to the slowness of receiving mechanical devices, 2 stop bits were used to give the device sufficient time to organize itself. Mark =1 0100000101Space =0 7-bit ASCII Character 12 Stop bits Start bit
  • 9. ECE473/573 Microprocessor System Design, Dr. Shiue 9 Parity Bit • Even-Parity bit system – 01001011 # of ‘1’=4 P=0 • Odd-Parity bit system – 01001011 # of ‘1’=4 P=1 • UART chips allow programming of the parity bit for odd-, even-, and no-parity options.
  • 10. ECE473/573 Microprocessor System Design, Dr. Shiue 10 Data Transfer Rate • Data Transfer Rate – Bits per second (bps) is also called Baud rate (the number of signals changes per second) – IBM PC/XT 100 ~ 9600 bps – Pentium PC 56k bps (recent MODEM) • Asynchronous data communication, the baud rate is limited to 100,000 bps. • Interfacing standard: RS232
  • 11. ECE473/573 Microprocessor System Design, Dr. Shiue 11 RS232 • PC: COM1 (Mouse), COM2: (MODEM & RS232) • RS232 is set by Electronics Industries Association (EIA) in 1960. • 1963: RS232A • 1965: RS232B • 1969: RS232C • RS232 is a serial I/O interfacing standard; however, since the standard was set long before the advent of the TTL logic family, its input and output voltage levels are not TTL compatible. • TTL is Transistor-Transistor Logic family (Bipolar transistor) in 1968
  • 12. ECE473/573 Microprocessor System Design, Dr. Shiue 12 Line Driver: MAX232 • RS232 is not compatible to TTL. For this reason, to connect any RS232 to a microcontroller system, we must use “Voltage Converters” such as MAX232 to convert the TTL logic levels to the RS232 voltage levels, and vice versa. • MAX232 IC chips is referred to as “Line Driver”.
  • 13. ECE473/573 Microprocessor System Design, Dr. Shiue 13 RS232 Connector: DB-25 • DB-25 Connector – DB-25P (Plug) – DB-25S (Socket) • DTE: Data Terminal Equipment: RS232 • DCE: Data Communication Equipment: MODEM 1 13 14 25 Pin 1: Ground Pin 2: TxD Pin 3: RxD :
  • 14. ECE473/573 Microprocessor System Design, Dr. Shiue 14 RS232 Connector: DB-9 • DB-9 Connector 1 5 6 9 Ring IndicatorRI9 Clear To Send!CTS8 Request To Send!RTS7 Data Set Ready!DSR6 GroundGND5 Data Terminal ReadyDTR4 TransmitTxD3 ReceiveRxD2 Data Carrier Detect!DCD1 descriptionfunctionPin
  • 15. ECE473/573 Microprocessor System Design, Dr. Shiue 15 8051 Connection to RS232 • Since RS232 standard is not TTL compatible, so we need MAX232 (line driver) 8051 MAX232 DB-9 (RS232 Connector) TxD RxD 11 (P3.1) 10 (P3.0) 11 T1 in T1 out 14 2 RxD 12 R1 out R1 in 13 3 TxD GND 5
  • 16. ECE473/573 Microprocessor System Design, Dr. Shiue 16 Baud Rate • Q1: With XTAL=11.0592MHz, find the TH1 value needed to have the following baud rate: (a) 9600, (b) 2400, and (c) 1200.
  • 17. ECE473/573 Microprocessor System Design, Dr. Shiue 17 SBUF Register • SBUF Register: For a byte of data to be transferred via the TxD line, it must be placed in the SBUF. • SBUF holds the byte of data when it is received by the 8051’s RxD line. 8051 MAX232 DB-9 (RS232 Connector) TxD RxD 11 (P3.1) 10 (P3.0) 11 T1 in T1 out 14 2 RxD 12 R1 out R1 in 13 3 TxD GND 5 Framed Deframed SBUF
  • 18. ECE473/573 Microprocessor System Design, Dr. Shiue 18 SCON Register RITIRB8TB8RENSM2SM1SM0 SCON 31 1 21 0 8 bit data, 1 stop bit , 1 start bit10 1 00 0 ModeSM0 SM1 • Mode 0, 2, and 3 are ready used today. • Mode 1 is compatible with the COM port of IBM PC. • Mode 1 allows the baud rate to be variable and is set by Timer 1 of 8051.
  • 19. ECE473/573 Microprocessor System Design, Dr. Shiue 19 SCON Register • SM2 enable the multiprocessing capability of the 8051. Here we make SM2=0. • REN: Receive Enable – REN=1: it allows the 8051 to receive data on the RxD pin. If you want the 8051 to both transfer and receive data, REN must be set to ‘1’. SETB SCON.4 – REN=0: make the receiver is disabled. • TB8: Transfer bit 8 – Is used for serial modes 2 and 3, so here we make TB8=0. D0D1D2D3D4D5D6D7Stop Bit 1 byte of data Bit 8
  • 20. ECE473/573 Microprocessor System Design, Dr. Shiue 20 SCON Register • RB8: Receive bit 8 – Is used for serial modes 2 and 3, so here we make RB8=0. • TI: Transmit Interrupt (this is a flag bit) – When 8051 finish the transfer of the 8-bit character, it raises the TI flag to indicate that it is ready to transfer another byte. • RI: Receive Interrupt – When 8051 receive data via RxD, it get rid of the start and stop bits (deframed procedure) and places the byte in the SBUF. – Then it raises the RI flag to indicate that a byte has been received and should be picked up before it is lost.
  • 21. ECE473/573 Microprocessor System Design, Dr. Shiue 21 Programming (Transfer) 1. MOV TMOD, #20H ; Timer 1, mode 2 2. TH1 is loaded to set the baud rate. 3. MOV SCON, #50H 4. SETB TR1 ; Run Timer 1 5. MOV SBUF, #’D’ 6. Loop: JNB TI, Loop ; Monitor TI 7. CLR TI 8. Repeat step 5 for next character. RI 0 TI 0 RB8 0 TB8 0 REN 1 SM2 0 SM1 1 SM0 0 SCON REN=1: allows TxD and RxD
  • 22. ECE473/573 Microprocessor System Design, Dr. Shiue 22 Examples • Q2: Write a program for the 8051 to transfer letter ‘A’ serially at 4800 baud rate, continuously. • Q3: Write a program to transfer the message “Yes” serially at 9600 baud, do this continuously.
  • 23. ECE473/573 Microprocessor System Design, Dr. Shiue 23 Programming (Receive) 1. MOV TMOD, #20H ; Timer 1, mode 2 2. TH1 is loaded to set the baud rate. 3. MOV SCON, #50H 4. SETB TR1 ; Run Timer 1 5. Loop: JNB RI, Loop ; Monitor RI 6. MOV A, SBUF 7. CLR RI 8. Repeat step 5 for next character. RI 0 TI 0 RB8 0 TB8 0 REN 1 SM2 0 SM1 1 SM0 0 SCON REN=1: allows TxD and RxD
  • 24. ECE473/573 Microprocessor System Design, Dr. Shiue 24 Examples • Q4: Program the 8051 to receive bytes of data serially, and put them in P1. Set the baud rate at 4800. • Q5: Write a program to (a) send to the PC the message “We Are Ready”, (b) receive any data sent by the PC and put it ob LEDs connected to P1, and (c) get data on switches and sent it to PC. The program should perform part (a) once, but parts (b) and (c) continuously. Use the 4800 baud rate.
  • 25. ECE473/573 Microprocessor System Design, Dr. Shiue 25 Doubling the Baud Rate • Method 1: Use a high XTAL – This method is infeasible since XTAL is fixed. – If you change XTAL, and then it is not compatible to PC. • Method 2: Change a bit in the PCON register • When 8051 is powered up, D7 of PCON =0, we could set D7 of PCON ‘1’ to double the baud rate. • Note that PCON is not bit addressible, so we need to do the following MOV A, PCON SETB ACC.7 MOV PCON, A IDLPDGF0GF1---SMOD PCON Serial Mode Bit
  • 26. ECE473/573 Microprocessor System Design, Dr. Shiue 26 Baud Rate for SMOD • Baud rate for SMOD = ‘0’ 11.0592MHz/12 = 921.6KHz 921.6KHz/32 = 28800Hz • Baud rate for SMOD = ‘1’ 11.0592MHz/12 = 921.6KHz 921.6KHz/16 = 57600Hz
  • 27. ECE473/573 Microprocessor System Design, Dr. Shiue 27 Baud Rate for SMOD E8-2424001200 F4-1248002400 FA-696004800 FD-3192009600 TH1 (Hex)TH1 (decimal)Baud Rate for SMOD=1 (Doubling the Baud Rate) Baud Rate for SMOD=0
  • 28. ECE473/573 Microprocessor System Design, Dr. Shiue 28 Examples • Q6: Assume XTAL=11.0592MHz, for the following program, state (a) what this program does (b) compute the frequency used by timer 1 to set the baud rate, and (c) find the baud rate of the data transfer. • Q7: Find the TH1 value (in both decimal and hex) to set the baud rate to each of the following (a) 9600, and (b) 4800 if SMOD=‘1’. Assume XTAL=11.0592MHz. • Q8: Find the baud rate if TH1 =-2, SMOD =1, XTAL=11.0592MHz. Is this baud rate supported by IBM PC