MAA Notes - Serial
MAA Notes - Serial
Asynchronous communication
Asynchronous serial communication is widely used for byte-oriented transmission.
PCON
It is 8-bit register. When 8051 is powered up, SMOD is zero. By setting the
SMOD, baud rate can be doubled. If SMOD = 0 (which is its value on reset), the
baud rate is 1/64 the oscillator frequency. If SMOD = 1, the baud rate is 1/32 the
oscillator frequency.
Program to transfer letter “D” serially at 9800baud, continuously:
MOV TMOD,#20H ; timer 1,mode 2(auto reload)
MOV TH1, #0FDH ; 9600 baud rate
MOV SCON, #50H ; 8-bit, 1 stop, REN enabled
SETB TR1 ; start timer 1
AGAIN: MOV SBUF, #”D” ; letter “D” to transfer
HERE: JNB TI, HERE ; wait for the last bit
CLR TI ;clear TI for next char
SJMP AGAIN ; keep sending A
Program to receive bytes of data serially, and put them in P2, set the baud
rate at 9600, 8-bit data, and 1 stop bit: