Title: Serial Communication with the 8031
1Serial Communication with the 8031
ECET3220
2Why Serial?
- 1 wire versus 8
- communicate over long distances
- no need to modulate/demodulate
- The 8031 has a built in UART!
- The 8031 has full duplex capability
- There are standard protocols such
- as RS232 (by the EIA in 1960!)
- Note RS232C is not TTL compatible! (a binary
1 -3 to 25 V and 0 3 to 25 V) MAX232 ICs are
available.
3How does it work?
- Framing the byte
- Overhead due to stop/start parity
- Baud (bps) sets the transfer rate
- There are many other standards
-
-
48031 Serial Pins
- RI (or RxD) is P3.0 (pin 10)
- TI (TxD) is P3.1 (pin 11)
5 68031 Serial Registers
- SBUF Used for transmission and
- reception of serial bytes
- SCON Used for initializing the
- the serial setup and INTs
- Timer1 Used for setting the baud
- rate. Note that you must divide the
- machine cycle frequency by 32 and
- use mode 2 (I.e 8 bit auto-reload)
- msb of PCON (not bit-addressable)
7Simple Program Snippet
MOV TMOD, 32 set T1 to mode 2 MOV TH1,
baud baud rate setup MOV SCON, 80 Mode 1,
REN 1 SETB TR1 start timer Repeat MOV SBUF
, A send 41h to the PC Wait JBC TI,
Repeat do again if done SJMP Wait wait
till last bit Tx
8More Modular approach
LCALL SendString db I am smarter than PCs said
the 8031, 0 SendString
9Now Receive some data
MOV TMOD, 32 set T1 to mode 2 MOV TH1,
baud baud rate setup MOV SCON, 80 Mode 1,
REN 1 SETB TR1 start timer Wait JNB RI,
Wait wait till data sent MOV R5, SBUF grab
the data CLR RI get ready to
repeat SJMP Wait
10(No Transcript)
11(No Transcript)