Académique Documents
Professionnel Documents
Culture Documents
8051 INTERFACING
Online FREE !
Serial Communication
RS-232 WAVEFORM
The diagram above, shows the expected waveform from the UART when using the common 8N1 format. 8N1 signifies 8 Data bits, No Parity and 1 Stop
Bit. The RS-232 line, when idle is in the Mark State (Logic 1). A transmission starts with a start bit which is (Logic 0). Then each bit is sent down the
line, one at a time. The LSB (Least Significant Bit) is sent first. A Stop Bit (Logic 1) is then appended to the signal to make up the transmission.
The data sent using this method, is said to be framed. That is the data is framed between a Start and Stop Bit .
This is the signal present on the RS-232 Port of your computer, shown below.
Standard serial interfacing of microcontroller (TTL) with PC or any RS232C Standard device , requires TTL to RS232 Level converter . A MAX232 is used
for this purpose. It provides 2-channel RS232C port and requires external 10uF capacitors.
MAX-232 includes a Charge Pump, which generates +10V and -10V from a single 5v supply.
http://www.freewebs.com/maheshwankhede/rs232.html 10/02/2010
8051 interfacing tutorials with RS232 logic devices with circuit c and assembly code & example Pgina 2 de 3
SCON
8 bit UART ,RN enabled , TI & RI operated by program. - 50hex
Timer 1 Count
TH1 = 256 - ((Crystal / 384) / Baud) -PCON.7 is clear.
TH1 = 256 - ((Crystal / 192) / Baud)-PCON.7 is set.
CODE EXAMPLE
http://www.freewebs.com/maheshwankhede/rs232.html 10/02/2010
8051 interfacing tutorials with RS232 logic devices with circuit c and assembly code & example Pgina 3 de 3
In Assembly Lan. prog. : Data is stored in string at pointer DATA. 0 is appended at end of string. In transmit subroutine data in string is transmitted till
0 is detected.
OUTCHAR:
mov sbuf,a ; place A into Serial Port 1 Buffer
WAITCHAR:
jnb ti,WAITCHAR ; wait buffer empty flag is set
clr ti ; clear buffer empty flag
ret
START:
;******************INITIALISATION*****************
mov TMOD, #20H ;T1 in mode 2
mov TH1, #-3 ;9600 baud
mov SCON, #50H ;8b, 1start, 1stop
anl PCON, #07fh ;To make SMOD =0
setb TR1 ;start T1
You can use same circuit for communicating with Mobile phones/GSM Module or GPS. Communicating with both of these require a Multiplexer ,which can
be implemented using NAND gates.
NAND gate as 2:1 Mux. which connects Rx of GSM modem or GPS receiver according to select bit logic level (pin P1.0 of uC)
http://www.freewebs.com/maheshwankhede/rs232.html 10/02/2010