Professional Documents
Culture Documents
www.pantechsolutions.net
SERIAL COMMUNICATION
Contrast and compare serial versus parallel communication List the advantages of serial communication over parallel Explain serial communication protocol Contrast synchronous versus asynchronous communication Contrast half-versus full-duplex transmission Explain the process of data framing Describe data transfer rate and bps rate Define the RS232 standard Explain the use of the MAX232 and MAX233 chips
SERIAL COMMUNICATION
Byte of data must be converted to serial bits using a parallel-in-serial-out shift register and transmitted over a single data line receiving end there must be a serial-in-parallel-out shift register if transferred on the telephone line, it must be converted to audio tones by modem for short distance the signal can be transferred using wire how PC keyboards transfer data to the motherboard 2 methods, asynchronous and synchronous synchronous method transfers a block of data (characters) at a time asynchronous method transfers a single byte at a time Uses special IC chips called UART (universal asynchronous receivertransmitter) and USART (universal synchronous asynchronous receivertransmitter) 8051 chip has a built-in UART
Technology beyond the Dreams
Copyright 2006 Pantech Solutions Pvt Ltd.
METHODS OF COMMUNICATION
SERIAL COMMUNICATION
BAUD RATE
Data transfer rate rate of data transfer bps (bits per second) widely used terminology for bps is baud rate baud and bps rates are not necessarily equal baud rate is defined as the number of signal changes per second Baud rate in the 8051 serial communications of the 8051 with the COM port of the PC must make sure that the baud rate of the 8051 system matches the baud rate of the PC's COM port can use Windows HyperTerminal program
PIN DESCRIPTION
DATA COMMUNICATION
Data communication classification
DTE (data terminal equipment) DCE (data communication equipment) DTE - terminals and computers that send and receive data DCE - communication equipment responsible for transferring the data simplest connection between a PC and microcontroller requires a minimum of three pins, TxD, RxD, and ground
MAX232
MAX232
converts from RS232 voltage levels to TTL voltage levels uses a +5 V power source MAX232 has two sets of line drivers for transferring and receiving data line drivers used for TxD are called T1 and T2 line drivers for RxD are designated as R1 and R2 T1 and R1 are used together for TxD and RxD of the 8051 second set is left unused
REGISTERS
solution
Machine cycle frequency: 11.0592 MHz/12 = 921.6kHz, Frequency provided by UART: 921.6kHz/32 =28,800 Hz (if SMOD=0) s or 921.6kHz/16 =57,600 Hz (if SMOD=1) should be provided by Timer 1 to set baud rate. Case I: SMOD=0. (a) 28,800/9,600 = 3. (b) 28,800/2,400 = 12. (c) 28,800/1,200 = 24. should be loaded into TH1.
Case II: SMOD=1. (a) 57,600/9,600 = 6. 256-6 (b) 57,600/2,400 = 24. 256-24 (c) 57,600/1,200 = 48. should be loaded into TH1. XTAL OSC
11.0592 MHz
57,600 Hz
921.6 kHz
12
32 by UART
(SMOD=0) 28,800 Hz
Timer 1
EXAMPLES
Write a program to transfer the message YES serially at 9600 baud, 8bit data, 1 stop bit. Do this continuously.
Solution:
MOV MOV MOV SETB MOV ACALL MOV ACALL MOV ACALL SJMP MOV JNB CLR RET TMOD,#20H TH1,#-3 ;9600 baud SCON,#50H TR1 A,#"Y" XMIT A,#"E" XMIT A,#"S" XMIT AGN ;timer 1, mode 2 ;8-bit, 1 stop bit, REN enabled ;start timer 1 ;transfer "Y" ;transfer "E" ;transfer "S" ;keep doing it ;serial data transfer subroutine
AGN:
XMIT: HERE:
SBUF,A ;load SBUF TI,HERE ;wait for last bit to transfer TI ;get ready for next byte
*/