© 2017 All Rights reserved  ·  E-Mail: admin@electronixforu.com
Electronix For You.......Train yourself in Electronics

8051 Based Serial Reception

Simulation File                           Hex File
Click the image to enlarge
8051 Minimum Hardware Required

Value of TH1 for different bauds

S. No Baud rate Value of TH1 (Decimal) Value of TH1 (Hex)
01 1200 -24 E8
02 2400 -12 F4
03 4800 -6 FA
04 9600 -3 FD
For details about serial communication refer to link

8051 based serial data receiver circuit and code is given below, this simulation will get the data from PCs UART and send its correspondance ASCII code to LEDs attached on port 1.
Baud rate is fixed with 9600, how ever one can change its baud rate by changing the value of TH1 (as shown in the table given below).
Circuit Expalaination:
The 8051 consists of Full duplex UART, but it is TTL based UART so a level converter IC MAX232 or equivalent is needed to properly establish a connection with PCs serial port. Pin no 10 of 8051 wich is serial receiver (Rx) pin is connected to PCs transmitter and pin no. 11 of 8051 Transmitter(Tx) is conected to the receiver of PC.
org 0                                       ;  Starting from 0  code memory location
mov p1, #00                             ;  All LEDs OFF by default
mov tmod, #20h                        ; Timer 1 mode 2, 8 bit auto relaod for serial communication
mov th1, #-3                             ; Set the baud rate
mov scon, #50h                        ; configure the UART, mode selection, 8 bit data, one stop bit, no parity, and receiver is enabled
setb tr1                                    ; start timer 1
wait:jnb ri, wait                          ; receiver interrupt, wait until unles a character from PC is received
mov a, sbuf                               ; once character is received by SBUF register it will be shifted to Register A
mov p1, a                                 ; send the received code to port 1 (LEDs)
clr ri                                         ;  RI receive interrupt which is raised(HIGH) is now cleared so that new data will be
sjmp wait