The 8051 Microcontroller Chapter 5 SERIAL PORT OPERATION





















- Slides: 21

The 8051 Microcontroller Chapter 5 SERIAL PORT OPERATION

• The essential function : parallel to serial conversion for output data and serial to parallel conversion for input data • Full duplex • Receive buffer • The serial port buffer (SBUF) is really 2 buffers • Writing to SBUF loads data to be transmitted, write-only register • Reading SBUF accesses received data, read-only register • SCON – serial port control register, control bits and status bits • Baud rate can be fixed or variable 2

3

4

• Mode of operation of serial port is set by writing to the SCON at address 99 H 5

8 -bit Shift Register (Mode 0) • The RXD line for input and output data • The TXD line serves as the clock 6

• Reception: reception enable bit REN=1 and receive interrupt bit RI=0 7

8 -bit Shift register (mode 0) • Possible application is to expand the output capability of the 8051 8

8 -bit UART with Variable Baud Rate (Mode 1) • Universal Asynchronous Receiver/Transmitter • Receives and transmits serial data with each data character preceded by a start bit (low) and followed by a stop bit (high) • For a receive operation, the stop bit goes into RB 8 in SCON 9

8 -bit UART (Mode 1) • Clocking and synchronizing the serial port shift registers in mod 1, 2, 3 is established by a 4 -bit divide‑by-16 counter, the output of which is the baud rate clock 10

8 -bit UART (Mode 1) • Transmission is initiated by writing ti SBUF but does not actually start until the next rollover of the divide-by-16 counter supplying the serial port baud rate • Reception is initiated by a 1 to 0 transition on RXD • The receiver includes “false start bit detection” 11

9 -bit UART with Fixed Baud Rate (Mode 2) • Eleven bits are transmitted or received: a start bit, 8 data bits, a programmable ninth data bit, and a stop bit 12

9 -bit UART with Variable Baud Rate (Mode 3) • Modes 1, 2 and 3 are very similar • The differences lie in the baud rates (fixed in the 2, variable in modes 1 and 3) and in the number of data bits( 8 in mode 1, 9 in modes 2 and 3) 13

Initialization and accessing serial port registers • Receiver Enable : REN in SCON must be set by software to enable the reception of characters • The ninth data bit : The ninth bit transmitted in modes 2 and 3 must be loaded into TB 8 by software, received bit is placed in RB 8 • Interrupt Flags : the receive and transmit interrupt flags (R 1 and T 1) in SCON, set by hardware, must be cleared by software 14

Multiprocessor Communication • Modes 2 and 3 have a special provision • When the master want to send some data to slaves, it first sends out an address byte of target slaves • The trick is not to use the ninth data bit after a link has been established 15

Serial Port Baud Rates • The baud rate is fixed in modes 0 and 3 • In mode 0 it is always the on-chip oscillator freq. divided by 12 • By default following a system reset, the mode 2 baud rate is the osci. freq. divided by 64 • Baud rates in modes 1 and 3 are determined by the timer 1 overflow rate 16

Using timer 1 as the Baud Rate Clock • The baud rate is the timer 1 overflow rate divided by 32 • The formula for modes 1 and 3 Baud rate=timer 1 overflow +32 17

18

19

20

21
Number of modes of operation of serial port are
Serial port programming in 8051
Pin diagram of 8051 microcontroller
8051 assembler
8051 basic
Internal memory organization of 8051 microcontroller
History of 8051 microcontroller
Addressing modes of 8051
Tr
Boolean processor of 8051
Introduction to microcontroller
Interrupt programming in 8051 using c
8051 interrupt structure
Different modes of operation of timer in 8051
Different types of addressing modes in 8051
Set b instruction
Flag register of 8051 microcontroller
Dc motor interfacing with 8051 microcontroller
Components of 8051 microcontroller
Timer and counter programming in 8051
8051 tmod register
8051 addressing modes