How to interface MAX232 with 8051 micrcontrollers?

October 30, 2011 | Anonymous | 0 comments

To receive data from i.e. a PC, you need a level converter, like a MAX232, or use standard components and make your own level converter (diagrams can be found via Google). A level converter is needed because the COMmunication port of a PC switches the data between approx. -9.23 to 9.23 Volt (I measured these levels, can vari a bit from PC to PC), -9.23 Volt corresponds with a logical '0' (lo), 9.23 Volt corresponds with a logical '1' (hi), both on TTL level of 5 Volt, so can be connected directly to the i/o's of an AVR. The MAX232 can convert at a maximum speed of 120kbit/sec. Here a very simple diagram of an RS232 converter (receive data only):

interface MAX232 with 8051

Not much components needed, only five electrolytical capacitors (elco's) and a MAX232. For the PC cable use shielded data cable. The UART (software) setup for the AVR is also very simple. First set the baudrate and enable the UART, like this:

ORG 0000H
MOV P2,#00;port 2 is made output port

;BEGINING OF RECEIVE OF DATA FROM SERIAL PORT
             MOV TMOD,#20H;Timer 1 Mode 2
              MOV TH1,#-3; 9600 baud rate
AGAIN: MOV SCON,#50H;8bit, 1stop bit,REN enabled
           SETB TR1;Start Timer 1
          CLR RI; RI is cleared for reception
RECV: JNB RI,RECV;wait for character to come in
         MOV A,SBUF;Moved received data into Accumulator
         CLR RI; Get Ready for next data
        SJMP RECV; Again go for receive data
END

Comments

Post Your Comment

Database based Nepali Date Converter

Convert Nepali date (B.S.) to English Date (A.D.) or Vice-Versa

Nepali Date
Gregorian Date

From 1900-01-01 A.D. to 2020-12-30 A.D.

From 1956/09/19 B.S. to 2077/09/15 B.S.

 

Download Nepali Date Converter

Like us on Facebook

Follow me on Google Plus

Follow me on Twitter