SlideShare a Scribd company logo
3
Most read
10
Most read
11
Most read
Timers, Counters & Serial I/O(Unit 5)
Session 7
Microcontroller & Applications
(IV Semester)
Electronics & Communication Engineering
Prepared by,
Ishwarkumar Nirale
GPT Mudhol
Electronics & Communication Engineering -15EC42TT
Contents:
• Serial data reception
• Sample programs
• Importance of the RI flag
• Interfacing RS232 to 8051
Electronics & Communication Engineering 15EC42T 2
Serial data reception
3
In programming of the 8051 to receive character bytes serially, the
following steps must be taken.
Step 1: The TMOD register is loaded with the value 20H, indicating
the use of Timer 1 in mode 2 (8-bit auto-reload) to set the baud rate.
Step 2: TH1 is loaded with one of the values (mentioned in baud rate
table) to set the baud rate (assuming XTAL = 11.0592MHz).
Step 3: The SCON register is loaded with the value 50H, indicating
serial mode 1, where 8-bit data is framed with start and stop bits and
receive enable is turned on.
Serial data reception
4
Step 4: TR1 is set to 1 to start Timer 1.
Step 5: RI is cleared with the “CLR RI” instruction.
Step 6: The RI flag bit is monitored to see if an entire character has
been received yet.
Step 7: When RI is raised, the contents of SBUF are moved into any
register.
Step 8: To receive the next character, go to Step 5.
Serial data reception
5
Flowchart:
Sample Programs
6
Write an ALP and 8051 in C to receive bytes of data serially and put them in P1. Set the
baud rate at 4800, 8-bit data, and 1 stop bit.
MOV TMOD, #20H
MOV TH1, #-6 ; 4800 baud
MOV SCON, #50H ; mode 1
SETB TR1
HERE:JNB RI, HERE ; wait for char to come in (RI=1)
MOV A, SBUF ; save incoming byte in A
MOV P1, A ; send to port 1
CLR RI ; clear, get ready for next byte
SJMP HERE ;Repeat
Sample Programs
7
8051 C Code
#include<reg51.h>
void main (void)
{
unsigned char mybyte;
TMOD=0x20;
TH1=0xFA;
SCON=0x50;
TR1=1;
while(1)
{
while(RI==0);
mybyte=SBUF;
P1=mybyte;
RI=0;
} }
Importance of RI flag bit
8
 To understand the importance of the role of RI, look at the
sequence of steps that the 8051 goes through in receiving a character
via RxD.
 The 8-bit character is received one bit at time. When the last bit is
received, a byte is formed and placed in SBUF. The stop bit is
received. When receiving the stop bit the 8051 makes RI = 1,
indicating that an entire character byte has been received and must be
picked up before it gets overwritten by an incoming character.
 By checking the RI flag bit when it is raised, we know that a
character has been received and is sitting in the SBUF register. We
copy the SBUF contents to a safe place in some other register or
memory before it is lost.
Importance of RI flag bit
9
 After the SBUF contents are copied into a safe place, the RI flag bit
must be forced to 0 in order to allow the next received character
byte to be placed in SBUF. Failure to do this causes loss of the
received character.
 From the above discussion we conclude that by checking the RI flag
bit we know whether or not the 8051 has received a character byte.
If we fail to copy SBUF into a safe place, we risk the loss of the
received byte. More importantly, it must be noted that the RI flag bit
is raised by the 8051, but it must be cleared by the programmer.
Interfacing RS232 to 8051
10
 The 8051 has two pins that are used specifically for transferring and
receiving data serially. These two pins are called TxD and RxD and
are part of the port 3 group (P3.0 and P3.1). Pin 11 of the 8051
(P3.1) is assigned to TxD and pin 10 (P3.0) is designated as RxD.
These pins are TTL compatible; therefore, they require a line driver
to make them RS232 compatible. One such line driver is the
MAX232 chip.
 Since the RS232 is not compatible with today’s microprocessors
and microcontrollers, we need a line driver (voltage converter) to
convert the RS232′s signals to TTL voltage levels that will be
acceptable to the 8051 ‘s TxD and RxD pins. One example of such
a converter is MAX232.
Interfacing RS232 to 8051
11
 The MAX232 converts from RS232 voltage levels to TTL voltage
levels, and vice versa. One advantage of the MAX232 chip is that it
uses a +5 V power source which, is the same as the source voltage
for the 8051. In other words, with a single +5 V power supply we
can power both the 8051 and MAX232, with no need for the dual
power supplies that are common in many older systems
Thank you
Electronics & Communication Engineering 15EC32T 12

More Related Content

PPTX
8051 MICROCONTROLLER ARCHITECTURE.pptx
PDF
Solution manual 8051 microcontroller by mazidi
PDF
DAC Interfacing with 8051.pdf
PPTX
Minimum mode and Maximum mode Configuration in 8086
PDF
Wideband Frequency Modulation.pdf
PPTX
Digital communications 1
PPTX
Fm demodulation using zero crossing detector
PDF
Programmable Logic Array(PLA) & Programmable Array Logic(PAL)
8051 MICROCONTROLLER ARCHITECTURE.pptx
Solution manual 8051 microcontroller by mazidi
DAC Interfacing with 8051.pdf
Minimum mode and Maximum mode Configuration in 8086
Wideband Frequency Modulation.pdf
Digital communications 1
Fm demodulation using zero crossing detector
Programmable Logic Array(PLA) & Programmable Array Logic(PAL)

What's hot (20)

PPTX
Code Conversion in 8085 Microprocessor
PDF
addressing-mode-of-8051.pdf
PDF
Mealy state machine
DOCX
Arm7 Interfacing examples
PDF
8051 interfacing
PDF
Question paper with solution the 8051 microcontroller based embedded systems...
PPT
Moore and Mealy machines
PPTX
Isolator & Circulator -FT.pptx
DOC
PIC MICROCONTROLLERS -CLASS NOTES
DOC
8051 Microcontroller Notes
PPTX
Serial Communication
PDF
Meley & moore
PPTX
Serial Communication in 8051
PPT
VLSI subsystem design processes and illustration
PPT
8255 presentaion.ppt
PPT
8051 serial communication-UART
PPT
Programming 8051 Timers
PDF
8155 PPI
PPTX
Coherent and Non-coherent detection of ASK, FSK AND QASK
PPTX
Phase Shift Keying & π/4 -Quadrature Phase Shift Keying
Code Conversion in 8085 Microprocessor
addressing-mode-of-8051.pdf
Mealy state machine
Arm7 Interfacing examples
8051 interfacing
Question paper with solution the 8051 microcontroller based embedded systems...
Moore and Mealy machines
Isolator & Circulator -FT.pptx
PIC MICROCONTROLLERS -CLASS NOTES
8051 Microcontroller Notes
Serial Communication
Meley & moore
Serial Communication in 8051
VLSI subsystem design processes and illustration
8255 presentaion.ppt
8051 serial communication-UART
Programming 8051 Timers
8155 PPI
Coherent and Non-coherent detection of ASK, FSK AND QASK
Phase Shift Keying & π/4 -Quadrature Phase Shift Keying
Ad

Similar to Serial communication in 8051 microcontroller (20)

PPTX
8051 serial communication1
PPT
12 mt06ped019
PPTX
INTERFACING 8051-MICROCONTROLLER with timer and display
PPT
Seminar on serial communication
PPT
Serial.ppt and it contains all information
PDF
EC8691 - UNIT 5.pdf
PDF
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
PPTX
Serial Io
PPTX
Sereial com. ppt
PPT
Chap10
PDF
Instruction Set Architecture and Design of Hardware
PDF
8051 Hardware Architecture, Addressing Modes, Interfacing
PDF
Pin Description of the 8051 along with I/O Interfacing
PDF
Introduction Architecture Addressing Modes
PDF
microcontroller intel 8051 pin description
PPT
Microcontroller 8051
PDF
Introduction to 8051 Microcontroller and its Architecture
PDF
Hardware Structures, Addressing Modes, Interrupt Control : 8051
PDF
Microcontroller Basics and Architecture of 8051
PDF
Microprocessor Techniques and Computer Organisation
8051 serial communication1
12 mt06ped019
INTERFACING 8051-MICROCONTROLLER with timer and display
Seminar on serial communication
Serial.ppt and it contains all information
EC8691 - UNIT 5.pdf
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
Serial Io
Sereial com. ppt
Chap10
Instruction Set Architecture and Design of Hardware
8051 Hardware Architecture, Addressing Modes, Interfacing
Pin Description of the 8051 along with I/O Interfacing
Introduction Architecture Addressing Modes
microcontroller intel 8051 pin description
Microcontroller 8051
Introduction to 8051 Microcontroller and its Architecture
Hardware Structures, Addressing Modes, Interrupt Control : 8051
Microcontroller Basics and Architecture of 8051
Microprocessor Techniques and Computer Organisation
Ad

Recently uploaded (20)

PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Geodesy 1.pptx...............................................
PPTX
OOP with Java - Java Introduction (Basics)
PPT
Mechanical Engineering MATERIALS Selection
PDF
Well-logging-methods_new................
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPT
Project quality management in manufacturing
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
composite construction of structures.pdf
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
Sustainable Sites - Green Building Construction
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Geodesy 1.pptx...............................................
OOP with Java - Java Introduction (Basics)
Mechanical Engineering MATERIALS Selection
Well-logging-methods_new................
R24 SURVEYING LAB MANUAL for civil enggi
Automation-in-Manufacturing-Chapter-Introduction.pdf
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Model Code of Practice - Construction Work - 21102022 .pdf
Project quality management in manufacturing
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
composite construction of structures.pdf
Foundation to blockchain - A guide to Blockchain Tech
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Sustainable Sites - Green Building Construction

Serial communication in 8051 microcontroller

  • 1. Timers, Counters & Serial I/O(Unit 5) Session 7 Microcontroller & Applications (IV Semester) Electronics & Communication Engineering Prepared by, Ishwarkumar Nirale GPT Mudhol Electronics & Communication Engineering -15EC42TT
  • 2. Contents: • Serial data reception • Sample programs • Importance of the RI flag • Interfacing RS232 to 8051 Electronics & Communication Engineering 15EC42T 2
  • 3. Serial data reception 3 In programming of the 8051 to receive character bytes serially, the following steps must be taken. Step 1: The TMOD register is loaded with the value 20H, indicating the use of Timer 1 in mode 2 (8-bit auto-reload) to set the baud rate. Step 2: TH1 is loaded with one of the values (mentioned in baud rate table) to set the baud rate (assuming XTAL = 11.0592MHz). Step 3: The SCON register is loaded with the value 50H, indicating serial mode 1, where 8-bit data is framed with start and stop bits and receive enable is turned on.
  • 4. Serial data reception 4 Step 4: TR1 is set to 1 to start Timer 1. Step 5: RI is cleared with the “CLR RI” instruction. Step 6: The RI flag bit is monitored to see if an entire character has been received yet. Step 7: When RI is raised, the contents of SBUF are moved into any register. Step 8: To receive the next character, go to Step 5.
  • 6. Sample Programs 6 Write an ALP and 8051 in C to receive bytes of data serially and put them in P1. Set the baud rate at 4800, 8-bit data, and 1 stop bit. MOV TMOD, #20H MOV TH1, #-6 ; 4800 baud MOV SCON, #50H ; mode 1 SETB TR1 HERE:JNB RI, HERE ; wait for char to come in (RI=1) MOV A, SBUF ; save incoming byte in A MOV P1, A ; send to port 1 CLR RI ; clear, get ready for next byte SJMP HERE ;Repeat
  • 7. Sample Programs 7 8051 C Code #include<reg51.h> void main (void) { unsigned char mybyte; TMOD=0x20; TH1=0xFA; SCON=0x50; TR1=1; while(1) { while(RI==0); mybyte=SBUF; P1=mybyte; RI=0; } }
  • 8. Importance of RI flag bit 8  To understand the importance of the role of RI, look at the sequence of steps that the 8051 goes through in receiving a character via RxD.  The 8-bit character is received one bit at time. When the last bit is received, a byte is formed and placed in SBUF. The stop bit is received. When receiving the stop bit the 8051 makes RI = 1, indicating that an entire character byte has been received and must be picked up before it gets overwritten by an incoming character.  By checking the RI flag bit when it is raised, we know that a character has been received and is sitting in the SBUF register. We copy the SBUF contents to a safe place in some other register or memory before it is lost.
  • 9. Importance of RI flag bit 9  After the SBUF contents are copied into a safe place, the RI flag bit must be forced to 0 in order to allow the next received character byte to be placed in SBUF. Failure to do this causes loss of the received character.  From the above discussion we conclude that by checking the RI flag bit we know whether or not the 8051 has received a character byte. If we fail to copy SBUF into a safe place, we risk the loss of the received byte. More importantly, it must be noted that the RI flag bit is raised by the 8051, but it must be cleared by the programmer.
  • 10. Interfacing RS232 to 8051 10  The 8051 has two pins that are used specifically for transferring and receiving data serially. These two pins are called TxD and RxD and are part of the port 3 group (P3.0 and P3.1). Pin 11 of the 8051 (P3.1) is assigned to TxD and pin 10 (P3.0) is designated as RxD. These pins are TTL compatible; therefore, they require a line driver to make them RS232 compatible. One such line driver is the MAX232 chip.  Since the RS232 is not compatible with today’s microprocessors and microcontrollers, we need a line driver (voltage converter) to convert the RS232′s signals to TTL voltage levels that will be acceptable to the 8051 ‘s TxD and RxD pins. One example of such a converter is MAX232.
  • 11. Interfacing RS232 to 8051 11  The MAX232 converts from RS232 voltage levels to TTL voltage levels, and vice versa. One advantage of the MAX232 chip is that it uses a +5 V power source which, is the same as the source voltage for the 8051. In other words, with a single +5 V power supply we can power both the 8051 and MAX232, with no need for the dual power supplies that are common in many older systems
  • 12. Thank you Electronics & Communication Engineering 15EC32T 12