Вы находитесь на странице: 1из 2

MOV TMOD,#00100000b

MOV TH1,#253d
MOV SCON,#01000000B
SETB REN
MOV PCON,#00h
SETB TR1
WAITLOOP:
JBC RI,GETDATA
SJMP WAITLOOP
GETDATA:
MOV A,SBUF
MOV P2,A
MOV SBUF,A
WAITX:
JNB TI,WAITX
CLR TI
SJMP WAITLOOP

T89S52 one-chip computer and PC serial communication design

O Foreword
One-chip computer and PC serial communication, are also called the serial communication of lower-
position unit and upper computer. Adopt this kind of communication mode, can solve the working
condition condition badly to the danger which staff members bring, can realize real-time online remote
centralized monitor, the scattered one-chip computer to working site adopts the control platform to
manage, can both improve the working condition and raise operating efficiency. This text designs for
circuit design and procedure of serial communication concrete exposition.
A circuit design
The communication interface standard is RS232, RS423A, RS422A, RS485,etc., the commonly used
interface standard is RS232 and RS485. RS232 adopts in the serial communication interface of the
computer extensively, is installing the modem (modem) additionally Situation under,there are can
through telephone line transmit data on kinds of communication, and it can transmit by thousands of
kilometer far distance, without it is more than ten meters far that modem can be transmitted. What this
subject is adopted is that RS-232 directly connect does not have modem way and DB-9 interface unit,
the one-chip computer adopts AT89S52, input end (RXD) serially that enables one-chip computer And
serial Ausgang (TXD) Link with COM port of the PC.
RS232 represents the logic state with positive negative voltage, regulations of representing the logic
state with TTL level level are different. So, in order to link with the computer interface or TTL device
is linked, must carry on the variety of level and logical relationship among RS232 and TTL. Realize
the this kind of variety method can be by setting up the component only, can use the integrated chip
too, this literary grace finishes TTL-EIA (American EIA) with MAX232 Two-way level switch. There
are voltage multiplying circuit and chance-over circuit within MAX232, only need +5 V power to
work, it is very convenient to use, it can adopt the simplest way to connect (see Fig. 1) while
connecting with AT89S52 ,The serial lines P3 of input aperture of T1 IN pin and 89S52 of MAX232.
1TXD links up, the serial lines P3 of input aperture of R1 OUT pin and 89S52. 0RXD links up, T1
OUT of MAX232, R1 IN, linking with 2, 3 pins of RS232 separately. MAX232 pump power pin must
connect 0. 1 f electric capacity) ; If PC or same two COM port of PC link, two 2, need to link up
alternately by 3 base pin of interface unit.
2 programmings
The design of the main program is: AT89S52 one-chip computer adopts the timer 1, works in the way
2, 11. The Jingzhen of 059 MHz, baud rate is 9 600 Hz, the time constant is FDH, are sent to the PC to
the sexadecimal contact signal ” aaH ” first from the one-chip computer ,Sum on answer BBH when it
is correct for PC to receive, with the array adr ‘ ] is as check sum, send the array tri while testing
normally ‘ ]. The intact program code is as follows:
Whether normal can debug software implementation through the serial port of installation of upper
computer in communication among upper and lower location machine, the above-mentioned
procedure runs after debugging software debugging normally.

Вам также может понравиться