Serial Modes - Notes New
Serial Modes - Notes New
1. RI must be zero. (i.e., the previously received byte has been cleared from SBUF)
2. Mode bit SM2 = 0 or stop bit = 1. After the data is received and the data byte has been loaded
into SBUF, RI becomes one.
Mode-3:
Multi-processor mode with variable baud rate: In this mode 11 bits are transmitted through TXD
or received through RXD. The various bits are: a start bit (usually '0'), 8 data bits (LSB first), a
programmable 9th bit and a stop bit (usually '1'). Mode-3 is same as mode-2, except the fact that
the baud rate in mode-3 is variable.
Programming of serial data communication in 8051:
In programming the 8051 to transfer character bytes serially
1. TMOD register is loaded with the value 20H, indicating the use of timer 1 in mode 2 (8-bit
auto-reload) to set baud rate
2. The TH1 is loaded with one of the values to set baud rate for serial data transfer
3. The SCON register is loaded with the value 50H, indicating serial mode 1, where an 8bit data
is framed with start and stop bits
4. TR1 is set to 1 to start timer 1
5. TI is cleared by CLR TI instruction
6. The character byte to be transferred serially is written into SBUF register
7. The TI flag bit is monitored with the use of instruction JNB TI, xx to see if the character has
been transferred completely
8. To transfer the next byte, go to step 5
Example: Write a program for the 8051 to transfer letter “A ”serially at 4800 baud, 8 bit
data, 1 stop bit continuously.
MOV TMOD, #20H //timer 1,mode 2(auto reload)
MOV TH1, #0FAH //4800 baud rate
MOV SCON, #50H // 8-bit, 1 stop, REN enabled
SETB TR1 // start timer 1
AGAIN: MOV SBUF, #”A” // letter “A” to transfer
HERE: JNB TI, HERE //wait for the last bit
CLR TI //clear TI for next char
SJMP AGAIN // keep sending A