written 6.3 years ago by |
The 8051 transfers and receives data serially at many different baud rates. The baud rate in the 8051 is programmable. This is done with the help of Timer 1.
There are two ways to increase or double the baud rate of data transfer in the 8051.
Use a higher-frequency crystal.
Change a bit in the PCON register, shown below.
Case number one is not feasible in many situations since the system crystal is fixed. More importantly, it is not possible because the new crystal may not be compatible with the IBM PC serial COM port’s baud rate. Hence case number two seems to be a better option. There is a software way to double the baud rate of the 8051 while the crystal frequency is fixed. This is done with the register called PCON (power control). The PCON register is an 8-bit register. Of the 8 bits, some are unused, and some are used for the power control capability of the 8051. The bit that is used for the serial communication is D7, the SMOD (serial mode) bit. When the 8051 is powered up, D7 (SMOD bit) of the PCON register is zero. We can set it to high by software and thereby double the baud rate. The following sequence of instructions will help to set high D7 of PCON, since it is not a bit-addressable register.
MOV A, PCON
SETB ACC.7
MOV PCON,A
There are two different cases for SMOD=1/0. Both these cases could be explained differently as follows.
CASE 1: Baud rates for SMOD = 0
When SMOD is set = 0, the 8051 divides 1/12 of the crystal frequency by 32 and uses that frequency for Timer 1 to set the baud rate. In the case of XTAL = 11.0592 MHz we have: Machine cycle freq. = 11.0592 MHz / 12 = 921.6 kHz and 921.6 kHz / 32 = 28,800 Hz as SMOD = 0.
CASE2: Baud rates for SMOD = 1
With the fixed crystal frequency, baud rate could be doubled by making SMOD – 1. When the SMOD bit is set to 1, 1/12 of XTAL is divided by 16 (instead of 32) and that is the frequency used by Timer 1 to set the baud rate. In the case of XTAL = 11.0592 MHz, we have: Machine cycle freq. = 11.0592 MHz / 12 = 921.6 kHz and 921.6 kHz / 16 = 57,600 Hz since SMOD = 1.