0% found this document useful (0 votes)
220 views1 page

Steps To Receive Data Serially in 8051

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
220 views1 page

Steps To Receive Data Serially in 8051

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Steps to Receive Data Serially in 8051 Microcontroller

1. Configure Timer 1: Load the TMOD register with the value 20H. This sets Timer 1 in
Mode 2 (8-bit auto-reload mode) for baud rate generation.

2. Set Baud Rate: Load the TH1 register with an appropriate value to configure the baud
rate. For example, TH1 = FDH sets the baud rate to 9600.

3. Initialize the Serial Port: Load the SCON register with the value 50H. This sets the
microcontroller to Serial Mode 1, enabling 8-bit UART communication with start and
stop bits.

4. Start Timer 1: Set TR1 to 1 using the SETB TR1 instruction to start Timer 1 for
generating the required baud rate.

5. Clear the Receive Interrupt (RI) Flag: Use the CLR RI instruction to ensure that the
RI flag is cleared before starting the data reception process.

6. Monitor the RI Flag: Continuously check the RI flag using an instruction like JNB
RI, xx. This flag is set when a full character byte is received.

7. Retrieve the Received Data: When the RI flag is raised, the received byte will be in
the SBUF register. Move the byte into a safe location, such as the accumulator or a
specific memory address.

8. Prepare for Next Character: To receive the next character, return to step 5 to clear
the RI flag and continue monitoring for incoming data.

Example in Assembly Code:


MOV TMOD, #20H ; Timer 1 in Mode 2 (auto-reload)
MOV TH1, #FDH ; Load TH1 for 9600 baud rate
MOV SCON, #50H ; Serial mode 1, 8-bit UART, enable receiver
SETB TR1 ; Start Timer 1

RECEIVE:
JNB RI, RECEIVE ; Wait for RI flag (character received)
MOV A, SBUF ; Move received data into accumulator
CLR RI ; Clear RI flag for next byte
; Process the data in A here
SJMP RECEIVE ; Repeat for the next character

You might also like