SlideShare a Scribd company logo
Serial Communication of 8051 Microcontroller
Dr. Nilesh Bhaskarrao Bahadure
https://www.sites.google.com/site/nileshbbahadure/home
July 25, 2021
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 1 / 73
Overview I
1 Universal Asynchronous Receiver Transmitter (UART)
2 Introduction to Serial Communication
3 Types of Transmission
Simplex Communication
Duplex Communication
Half Duplex Communication
Full Duplex Communication
4 Methods of Serial data Transmission
Synchronous serial data transfer
Asynchronous serial data transfer
Differences Synchronous Asynchronous
5 Data Transfer Rate
6 Calculation of Baud Rate
7 SCON Register
Importance of TI Flag Bit
Importance of RI Flag Bit
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 2 / 73
Overview II
8 SBUF Register
9 Writing to the Serial port
10 Reading the Serial port
11 PCON Register
12 Programming of transmission byte serially
13 Programming of reception of byte serially
14 Examples
Example -1: Transmission of N
Example -2: Transmission of N
Example -3: Receive byte serially
Example -4: Transmission of multiple byte serially
Example -5: Transmission & Reception byte serially
Example - 6: Switch base Yes - No
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 3 / 73
Universal Asynchronous Receiver Transmitter (UART)
UARTs are used for serial communication between systems; they can be
either half duplex (send or receive but at different intervals) or full duplex
(send and receive at the same time). Also known as an RS232 connection
the microcontroller UART can provide the connection with a PC or another
Microcontroller-based system. Figure 1 illustrates possible connection ar-
rangements. In a minimum connection there could be only two transmission
lines, transmit (Tx) and receive (Rx) as shown in Figure 2. The data is con-
veyed as a bit stream, either transmit or receive, and the speed is defined
by the baud rate i.e. the bits per second.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 4 / 73
Universal Asynchronous Receiver Transmitter (UART)...
Figure : Use of RS232 interface between PC and Microcontroller or between two
microcontrollers
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 5 / 73
Universal Asynchronous Receiver Transmitter (UART)...
Figure : RS 232 transmit (Tx) and Receive (Rx) connections between a PC and
Microcontroller
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 6 / 73
Universal Asynchronous Receiver Transmitter (UART)...
The UART has four modes of operation, 0 to 3. Modes 0 and 2 have fixed
baud rates, mode 0 is one-sixth of the oscillator frequency, and mode 2 is
1/16 or 1/32 of the oscillator frequency. For modes 1 and 3 the baud rate
can be selected, a typical range is:
75; 150; 300; 600; 1200; 2400; 4800; 9600; 19200; 38400
Modes 0 and 1 are used for connection between two devices. Modes 2 and 3
are used for master slave multiprocessor systems, in principle there could be
one master microcontroller and up to 255 slave microcontrollers. In mode
1 ten bits are used to specify an RS232 frame consisting of 1 start bit (logic
0), 8 data bits and 1 stop bit (logic 1). For example the ASCII bit pattern
0100 0001 (hex 41) represents the character ’A’ and is transmitted as shown
in Figure 3; least significant bit (LSB) first.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 7 / 73
Universal Asynchronous Receiver Transmitter (UART)...
Figure : ASCII bit pattern 01000001 (41h) for character ’A’
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 8 / 73
Introduction to Serial Communication
One of the 8051s most powerful features is its integrated UART, otherwise
known as a serial port. The fact that the 8051 has an integrated serial port
means that you may very easily read and write values to the serial port.
If it were not for the integrated serial port, writing a byte to a serial line
would be a rather complicated process requiring turning ON and OFF one
of the I/O lines in rapid succession to properly “clock out” each individual
bit, including start bits, stop bits, and parity bits.
Actually, if the serial communication port is not integrated within the chip
then proper synchronization between the transmitter and the receiver is
very complicated process. However, we do not have to do this. Instead,
we simply need to configure the serial ports operation mode and baud rate.
This configuration can be done by writing very simple code, may requires
only 5 to 8 lines of code. Once configured, all we have to do is write to
an SFR to write a value to the serial port or read the same SFR to read a
value from the serial port.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 9 / 73
Types of Transmission
Serial communication is capable of processing or transmitting of information
by 2 types they are Simplex communication and Duplex communication.
Further the duplex communication is also of 2 types, they are, half duplex
communication and full duplex communication.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 10 / 73
Simplex Communication
In the simplex communication, the serial data is transmitted only in one
direction, i.e. from transmitter to receiver.
The simplex is a one way transmission, data is transferred only in one di-
rection over a single communication channel. For example Microprocessor
transmit data to the Printer, Microprocessor transmit data to the CRT dis-
play unit.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 11 / 73
Simplex Communication...
Figure : Simplex Transmission
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 12 / 73
Duplex Communication
The Duplex is a two way transmission; data may be transferred between
two transceivers in both directions simultaneously. So it will contain one
way transmission or two way transmission at a time. For example Telephone
line.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 13 / 73
Half Duplex Communication
The Half Duplex is a two way transmission but in such a way that data may
travel in only one direction at a time. For example Wacky Talky (Wireless
System).
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 14 / 73
Full Duplex Communication
The full duplex is a two way transmission (communication) but in such a
way that the data may travel in both the direction at the same time. For
example Telephone line, mobile communication etc.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 15 / 73
Duplex Communication...
Figure : Duplex Transmission
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 16 / 73
Methods of Serial data Transmission / Format of serial
data transmission
In modern data communication system for the data transfer two types of
format are used Synchronous and Asynchronous.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 17 / 73
Synchronous serial data transfer
In this method block of data bytes are transferred serially at a time. The
numbers of data bytes are not limited. The data bytes are transferred one
after the other and so on up to the end. In this method at the starting of
data transfer, first transfer synchronous characters one synchronous char-
acter is compulsory for the data transfer and 2nd is optional. Synchronous
characters are inform to the receiver will start the transferring of data i.e.
its provide synchronization between transmitter and receiver. In one syn-
chronous character 256 receivers are connected i.e. from 00 to FFh. As
the synchronization is done only once and before the start of data transfer,
the synchronous communication is faster compared to asynchronous com-
munication. So it is generally used for fast data transfer at high rate. The
synchronous data format with two synchronous characters is shown in the
figure 6
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 18 / 73
Synchronous serial data transfer
Figure : Synchronous data format
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 19 / 73
Asynchronous serial data transfer
In this method block of data bytes are transferred serially at a time. The
numbers of data bytes are not limited. The data bytes are transferred one
after the other and so on up to the end. In this method at the starting of
data transfer, first transfer synchronous characters one synchronous char-
acter is compulsory for the data transfer and 2nd is optional. Synchronous
characters are inform to the receiver will start the transferring of data i.e.
its provide synchronization between transmitter and receiver. In one syn-
chronous character 256 receivers are connected i.e. from 00 to FFh. As
the synchronization is done only once and before the start of data transfer,
the synchronous communication is faster compared to asynchronous com-
munication. So it is generally used for fast data transfer at high rate. The
synchronous data format with two synchronous characters is shown in the
figure 7
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 20 / 73
Asynchronous serial data transfer
Figure : Asynchronous data format
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 21 / 73
Differences Between Synchronous & Asynchronous Data
Transfer
Synchronous data transfer Asynchronous data transfer
It is used to transfer a group of
Characters at a time.
It is used to transfer one char-
acter at a time
Used for high data transfer
rates 20 K bits / second
Used for data transfer rates 20
K bits / second
Synchronous character are
transmitted along with the
group of characters
Synchronous characters are not
transmitted along with the
characters
No start and stop bits for each
character is used
Start and stop bit for each char-
acter is present which forms a
frame
Table : Differences Syn Asynch
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 22 / 73
Differences Between Synchronous & Asynchronous Data
Transfer...
Synchronous data transfer Asynchronous data transfer
One clock is used for both
transmitter and receiver
Two separate clock inputs can
be used for transmitter and re-
ceiver
Since synchronization is in-
volved, this can be imple-
mented by using hardware only
No synchronization is required
hence hardware and software
implementation is possible.
Table : Differences Syn Asynch
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 23 / 73
Data Transfer Rate / Baud Rate
Data transfer rate is defined as the number of bits are transmitted or re-
ceived in one second. Usually it is referred as bits per second (BPS) and
sometimes it is also called baud rate (BR). Transmission of the serial data
requires configuring baud rate, actually at the baud rate it was defines that
how many bits to be transferred in one second. It is not possible to con-
figure data transfer serially without configuring baud rate. It is important
to note that, it is not necessary that bits per second and baud rate are
same. Because the baud rate is used in reference to MODEM (Modulator
- Demodulator), where number of signal changes indicate bits transmission
and in single signal change may indicate more data bits are transmitted,
whereas if conductor based transmission is concerned then bits per second
and baud rate are same.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 24 / 73
Data Transfer Rate / Baud Rate...
Baud rate in 8051 Microcontroller is programmable, means that different
baud rates can be easily achieved without any hardware configuration or
modifications; this is simply done by writing a set of instructions. The
8051 Microcontroller divides crystal frequency by 12 to get the machine
cycle frequency, in other words we say that internal frequency is the 1/12th
of crystal frequency (External frequency). Serial communication UART
circuitry once again divides this frequency i.e. machine cycle frequency by
32 or 16, depending on the status of SMOD bit in the PCON register to use
by timer 1 to generate baud rate. in other words we may say that on chip
UART circuitry uses the frequency after diving the machine cycle frequency
by 32 or 16 for calculation of baud rate.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 25 / 73
Data Transfer Rate / Baud Rate...
Figure : Setting baud rate for SMOD =0
Figure : Setting baud rate for SMOD =1
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 26 / 73
Data Transfer Rate / Baud Rate...
To set baud rate compatible with IBM PCs timer 1 must be operated in
auto reload mode. The reason behind to use the auto reload mode is that,
it is possible to get maximum overflows (ticks) at very high rate only in
auto reload mode.
The values to be loaded in TH1 register and their corresponding baud rate
compatible with IBM PCs are shown in the table 3
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 27 / 73
Data Transfer Rate / Baud Rate...
TH1 (Decimal) TH1 (Hex) Baud Rate
-3 FDh 9600
-6 FAh 4800
-12 F4h 2400
-24 E8h 1200
-48 D0h 600
Table : Timer 1 TH1 Register Value for the Baud Rate
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 28 / 73
Calculation of Baud Rate
In mode 1 and 3, the baud rate is determined by how frequently timer 1
overflows. The more frequently timer 1 overflows, the higher the baud rate
i.e. how fast the timer flag bit overflows that decides baud rate. In other
words we can say that baud rate is directly related with timer flag rollover.
There are many ways one can cause timer 1 to overflow at a rate that
determines a baud rate but the most common method is to put timer 1 in 8
- bit auto - reload mode (timer mode 2) and set a reload value (TH1) that
causes timer 1 to overflow at a frequency appropriate to generate a baud
rate.
To determine the value that must be loaded in TH1 register to generate a
given baud rate, we may use the following equation:
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 29 / 73
Calculation of Baud Rate...
TH1 = 256 − 2SMOD ×Oscillator Frequency
12×32×Baud Rate
TH1 = 256 − 2SMOD ×Oscillator Frequency
384×Baud Rate
if SMOD = 0
TH1 = 256 − Oscillator Frequency
384×Baud Rate
if SMOD = 1
TH1 = 256 − Oscillator Frequency
192×Baud Rate
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 30 / 73
SCON Register
D7 D6 D5 D4 D3 D2 D1 D0
SM0 SM1 SM2 REN TB8 RB8 TI RI
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 31 / 73
SCON Register...
Bit Name Bit address Function
7 SM0 9Fh
Serial port mode bit 0
6 SM1 9Eh
Serial port mode bit 1
5 SM2 9Dh
Multiprocessor communication
enable bit
4 REN 9Ch
Receiver enables. This bit must
be set in order to receive char-
acters serially.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 32 / 73
SCON Register...
Bit Name Bit address Function
3 TB8 9Bh
Transmit bit 8. The 9th bit to
transmit in mode 2 and mode 3
2 RB8 9Ah
Receive bit 8. The 9th bit re-
ceived in mode 2 and mode 3
1 TI 99h
Transmit flag. Set when a
byte has been transmitted com-
pletely.
0 RI 98h
Receive flag. Set when a byte
has been received completely.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 33 / 73
SCON Register...
SM0 SM1 Serial mode Explanation Baud rate
0 0 0 8 - bit shift register Oscillator/12
0 1 1 8 - bit UART Set by timer 1
1 0 2 9 - bit UART Oscillator/32
1 1 3 9 - bit UART Set by timer 1
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 34 / 73
Importance of TI Flag Bit
The following steps are observed when the character byte transferred serially
via TxD line
1. The start bit is transmitted; indicate that data transmitted is going to
be start.
2. The 8 - bit main value of the character byte start transmission with LSB
(bit D0) first.
3. The stop bit is transmitted. The stop bit is the last bit to be transmitted
if the parity bit is not considered. It is during the transmission of stop bit,
TI flag bit is raised to one (logic high) by CPU, indicating that transmission
is completed. So 8051 is ready to transfer a new character byte.
4. By monitoring TI flag bit we ensure that the previous byte is transmitted
completely or not. Suppose TI flag bit doesn’t raises and we are trying to
send new character, so there may be chances that some bits of the previous
byte are lost and new character gets transmitted. In other words TI flag bit
is raised by CPU in order to ensure proper transmission of data bits.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 35 / 73
Importance of TI Flag Bit..
5. When TI rises it must be forced to zero by software program in order to
transmit next character or byte.
From the above points it is clear that when 8051 Microcontroller finishes
transmission, it will raise TI flag bit automatically, gives the information
that transmission is completed in all respects.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 36 / 73
Importance of RI Flag Bit
In receiving bits via its RxD line, the 8051 Microcontroller goes through the
following steps
1. It receives the start bit, indicating that the next bit is the first bit of the
character byte it is about to receive.
2. The 8 - bit character is received one bit at a time, The LSB i.e. D0 bit
receives first. When the last bit (bit D7) is received, a byte is formed and
placed in the SBUF register.
3. The stop bit is received, when receiving the stop bit the 8051 makes RI
= 1, indicating that an entire character byte has been received and must
be picked up before it gets over written by an incoming character.
4. By checking the RI flag bit when it is raised, we know that the character
has been received and it is available in the SBUF register. We must copy the
SBUF register contents to a safe place in some other register or in memory
before it is lost.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 37 / 73
Importance of RI Flag Bit...
5. After the SBUF contents are copied into a safe place, the RI flag bit
must be forced to 0 by the software instruction CLR RI in order to allow the
next received character byte to be placed in SBUF, failure to do this causes
loss of the received character.
From the above, we conclude that by checking the RI flag bit, we know
whether or not the 8051 has received a character byte. If we fail to copy
SBUF into a safe place, we risk the loss of the received byte. More impor-
tantly, it must be noted that RI flag bit is raised by the 8051, but it must
be cleared by the programmer with an instruction such as CLR RI. It must
also be noted that if we copy SBUF into a safe place before the RI flag bit
is raised, we risk copying the garbage.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 38 / 73
SBUF Register
The SBUF register is used to load the data to be transmitted serially. The
data received serially by 8051 Microcontroller is also copied to the SBUF
register. The ON chip address of SBUF register is 99h. The SBUF register
is also access like any other register of 8051 Microcontroller for example, to
load data 34h to the SBUF register then, it may written as
MOV SBUF, #34h or MOV 99h, #34h
Similarly the data from SBUF register is copied to any other register, for
example MOV A, SBUF
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 39 / 73
Writing to the serial port
Once the Serial Port has been properly configured as explained above, the
serial port is ready to be used to send data and receive data. If you thought
that configuring the serial port was simple, using the serial port will be a
breeze. To write a byte to the serial port one must simply write the value
to the SBUF (99h) SFR.
For Example, if you wanted to send the letter “A” to the serial port, it could
be accomplished as easily as:
MOV SBUF, #’A’
Upon execution of the above instruction the 8051 will begin transmitting the
character via the serial port. Obviously transmission is not instantaneous–it
takes a measureable amount of time to transmit
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 40 / 73
Writing to the serial port
The 8051 lets us know when it is done transmitting a character by setting
the TI bit in SCON. When this bit is set we know that the last character has
been transmitted and that we may send the next character, if any. Consider
the following code segment:
CLR TI ; be sure the bit is initially clear
MOV SBUF, #’A’ ; Send the letter A to the serial port
JNB TI, $ ; Pause until the RI bit is set.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 41 / 73
Reading the serial port
Reading data received by the serial port is equally easy. To read a byte
from the serial port one just needs to read the value stored in the SBUF
(99h) SFR after the 8051 has automatically set the RI flag in SCON. For
example, if your program wants to wait for a character to be received and
subsequently read it into the Accumulator, the following code segment may
be used:
JNB RI, $ ; Wait for the 8051 to set the RI flag
MOV A, SBUF ; Read the character from the serial port
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 42 / 73
PCON Register
Question
Explain how to double the baud rate without changing crystal frequency
D7 D6 D5 D4 D3 D2 D1 D0
SMOD – – – GF1 GF0 PD IDL
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 43 / 73
PCON Register...
There are two ways to increase the baud rate of data transfer in the 8051
Microcontroller
1. Use a higher frequency crystal
2. Change a bit in the PCON register, i.e. bit D7 (SMOD) bit of PCON
register
When the 8051 is powered up, D7 bit of the PCON register is zero, we can
set this bit to HIGH by software and thereby double the baud rate. The
following sequence of the instructions must be used to set bit D7 HIGH of
the PCON register, since PCON is not a bit addressable register. There
may be more methods to set SMOD = 1, without affecting the other bits of
PCON register, so one may use any sequence of the program with ensuring
that the other bits of the PCON register is unaffected and only SMOD gets
high.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 44 / 73
PCON Register...
MOV A, PCON ; get original or old value of PCON register in Accumulator
SETB ACC.7 ; make D7 (SMOD) = 1
MOV PCON, A ; now SMOD = 1 without modifying other bits of the PCON
register
Alternatively,
MOV A, PCON ; get original or old value of PCON register in Accumulator
OR A, #0FFh ; make D7 (SMOD) = 1
MOV PCON, A ; now SMOD = 1 without modifying other bits of the PCON
register
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 45 / 73
Calculation of Baud Rate...
TH1 = 256 − 2SMOD ×Oscillator Frequency
12×32×Baud Rate
TH1 = 256 − 2SMOD ×Oscillator Frequency
384×Baud Rate
if SMOD = 0
TH1 = 256 − Oscillator Frequency
384×Baud Rate
if SMOD = 1
TH1 = 256 − Oscillator Frequency
192×Baud Rate
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 46 / 73
Baud rate comparision for SMOD = 0 & SMOD = 1
Baud rate comparisons for SMOD = 0 and SMOD =1 is shown in the table
below. It shows that the for the same value of TH1, the baud rate are
doubled when SMOD = 1
TH1 (Decimal) TH1 (Hex) Baud Rate
SMOD = 0 SMOD = 1
-3 FDh 9600 19200
-6 FAh 4800 9600
-12 F4h 2400 4800
-24 E8h 1200 2400
-48 D0h 600 1200
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 47 / 73
Programming of transmission byte serially
The following steps are taken to transmit a character or byte serially through
the TxD line of 8051 Microcontroller.
1. The TMOD register must be initialized with 20h indicating that timer
1 in auto - reload mode (mode 2), to set the baud rate. The baud rate
is configured only using auto - reload mode, because only in auto - reload
mode it is possible to get maximum overflow at very high rate.
2. Load TH1 register with a value corresponding to the specified baud rate.
3. Initialize SCON register with value 50h indicating serial mode 1 i.e. 8 -
bit data, 1 start bit and 1 stop bit. In most of the system use only serial
mode 1, because this mode is IBM compatible.
4. Set TR1 = 1 to start the timer 1, to get the baud rate.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 48 / 73
Programming of transmission byte serially...
5. The character byte to be transmitted serially must be put in the SBUF
register.
6. Keep monitoring TI (transmitter interrupt) flag bit using the instruction
“CHECK: JNB TI, CHECK”, in order to ensure that transmission is com-
pleted or not. When TI rises, indicates completion of the transmission of
character them go out of the loop.
7. Clear TI flag bit using instruction CLR TI
8. In order to repeat the process, i.e. to transmit another character or byte
go to step 5. No need to start the timer again, as once the baud rate is
configured; it is available throughout the completion of the program. The
baud rate is change again by loading another value in TH1 register and start
the timer or it may gets laps by resetting the system.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 49 / 73
Programming of reception of byte serially
The following steps are followed to receive character or byte serially through
the RxD line of 8051 Microcontroller.
1. The TMOD register must be initialized with 20h indicating that timer
1 in auto - reload mode (mode 2), to set the baud rate. The baud rate
is configured only using auto - reload mode, because only in auto - reload
mode it is possible to get maximum overflow at very high rate.
2. Load TH1 register with a value corresponding to the specified baud rate.
3. Initialize SCON register with value 50h indicating serial mode 1 i.e. 8 -
bit data, 1 start bit and 1 stop bit. In most of the system use only serial
mode 1, because this mode is IBM compatible.
4. Set TR1 = 1 to start the timer 1, to get the baud rate.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 50 / 73
Programming of reception of byte serially...
5. Keep monitoring RI (receiver interrupt) flag bit using the instruction
“CHECK: JNB RI, CHECK”, in order to ensure that reception is completed
or not. When RI rises, indicates completion of the reception of character
then go out of the loop.
6. When RI flag bit is rises then there is a byte i.e. received byte in SBUF
register, so it must be picked up before a new incoming character is received.
In other words when RI is rises then store the SBUF contents in safe place.
7. Clear RI flag bit using instruction CLR RI
8. In order to repeat the process, i.e. to receive another character or byte
go to step 5. No need to start the timer again, as once the baud rate is
configured; it is available throughout the completion of the program. The
baud rate is change again by loading another value in TH1 register and start
the timer or it may gets laps by resetting the system.
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 51 / 73
Example -1: Transmission of character N serially
Example - 1
8051 Microcontroller has an oscillator frequency of 11.0592MHz. Using
timer 1 and configuring the UART in mode 1 write an assembly language
program that transmits the ASCII character “N” at a baud rate of 9600.
Solution
TH1 = 256 − 2SMOD ×Oscillator Frequency
12×32×Baud Rate
(Assume) SMOD = 0
By putting baud rate 9600, we get
TH1=FDh
Calculate TMOD and SCON
TMOD = 20h
SCON = 50h
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 52 / 73
Example -1: Transmission of character N serially
Assembly Language Program
ORG 0 ; reset address
SJMP START ; jump over reserved area
ORG 40H ; program start address
START: MOV SCON, #50H ; serial mode 1
MOV TMOD, #20H ; timer 1 mode 2
MOV TH1, #0FDH ; baud rate 9600
SETB TR1 ; turn timer 1 on
AGAIN: MOV SBUF, #’N’ ; ASCII of N into SBUF
HERE: JNB TI, HERE ; stay here till TI is set
CLR TI ; clear TI
SJMP AGAIN ; repeat
END ; end of assembly language
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 53 / 73
Example -2: Transmission of character N serially
Example - 2
8051 Microcontroller has an oscillator frequency of 11.0592MHz. Using
timer 1 and configuring the UART in mode 1 write an assembly language
program that transmits the ASCII character “N” at a baud rate of 19200.
Solution
TH1 = 256 − 2SMOD ×Oscillator Frequency
12×32×Baud Rate
(Assume) SMOD = 0
By putting baud rate 19200, we get
TH1=FEh
Calculate TMOD and SCON
TMOD = 20h
SCON = 50h
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 54 / 73
Example -2: Transmission of character N serially
Assembly Language Program
ORG 0 ; reset address
SJMP START ; jump over reserved area
ORG 40H ; program start address
START: MOV SCON, #50H ; serial mode 1
MOV TMOD, #20H ; timer 1 mode 2
MOV TH1, #0FEH ; baud rate 9600
SETB TR1 ; turn timer 1 on
AGAIN: MOV SBUF, #’N’ ; ASCII of N into SBUF
HERE: JNB TI, HERE ; stay here till TI is set
CLR TI ; clear TI
SJMP AGAIN ; repeat
END ; end of assembly language
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 55 / 73
Example -3: Receive byte serially and send to port P1
Example - 3
8051 Microcontroller has an oscillator frequency of 11.0592 MHz. Write an
assembly language program that receives a character into the serial buffer
(SBUF) of the UART and writes the hex value of the character onto port
1. The UART should be configured as mode 1. Use 9600 baud rate.
Solution
TH1 = 256 − 2SMOD ×Oscillator Frequency
12×32×Baud Rate
(Assume) SMOD = 0
By putting baud rate 9600, we get
TH1=FDh
Calculate TMOD and SCON
TMOD = 20h
SCON = 50h
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 56 / 73
Example -3: Receive byte serially
Assembly Language Program
ORG 0 ; reset address
SJMP START ; jump over reserved area
ORG 40H ; program start address
START: MOV SCON, #50H ; mode 1, REN enabled
MOV TH1, #0FDH ; 9600 baud
MOV TMOD, #20H ; timer 1 mode 2
SETB TR1 ; turn timer 1 on
STAY: JNB RI, STAY ; stay here, until RI = 1
CLR RI ; clear RI
MOV A, SBUF ; move character from buffer to A
MOV P1, A ; hex value onto port 1
RETI ; return from interrupt
END ; no more assembly language
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 57 / 73
Example -4: Transmission of message BHEL serially
Example - 4
8051 Microcontroller has an oscillator frequency of 11.0592 MHz. write
an assembly language program to transfer the message “BHEL” serially at
4800 baud rate, 8 - bit data, 1 start bit and 1 stop bit. Send the message
continuously.
Solution
TH1 = 256 − 2SMOD ×Oscillator Frequency
12×32×Baud Rate
(Assume) SMOD = 0
By putting baud rate 4800, we get
TH1=FAh
Calculate TMOD and SCON
TMOD = 20h
SCON = 50h
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 58 / 73
Example -4: Trans. of byte serially (Method - I)
Assembly Language Program
ORG 0
SJMP START
ORG 0040H
START: MOV TMOD, #20H
MOV TH1, #-6 / MOV TH1, # 0FAH
MOV SCON, #50H
SETB TR1
AGAIN: MOV A, #’B’
ACALL SEND
MOV A, #’H’
ACALL SEND
MOV A, #’E’
ACALL SEND
MOV A, #’L’
ACALL SEND
SJMP AGAIN
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 59 / 73
Example -4: Trans. of byte serially (Method - I)...
Assembly Language Program
SEND: MOV SBUF, A
HERE: JNB TI, HERE
CLR TI
RET
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 60 / 73
Example - 4: Trans. of byte serially (Method - II)
Assembly Language Program
ORG 0
SJMP START
ORG 0040H
START: MOV TMOD, #20H
MOV TH1, #-6 / MOV TH1, #0FAH
MOV SCON, #50H
SETB TR1
LAST: MOV DPTR, #MSG
AGAIN: CLR A
MOVC A, @A+DPTR
JZ LAST ; If last character get o
repeat again
ACALL SEND
INC DPTR
SJMP AGAIN
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 61 / 73
Example - 4: Trans. of byte serially (Method - II)...
Assembly Language Program
SEND: MOV SBUF, A
HERE: JNB TI, HERE
CLR TI
RET
MSG: DB ’BHEL’, 0
END
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 62 / 73
Example -5: Transmission & Reception byte serially
Example - 5
Assume that the 8051 microcontroller’s serial port is connected to the COM
port of the IBM PC, and on the PC we are using the Hyper Terminal program
to send and receive data serially. Port P1 and P2 of the 8051 are connected
to the LED’s and switches respectively. Write an assembly language program
to perform the following
1. Send to the PC the message “Microcontroller is ready”
2. Receive any data sent by the PC and put it on LEDs connected to the
port P1.
3. Get data on switches connected to port P2 and send it to the PC
serially. The program should perform in part (1) once but part (2) and (3)
continuously. Assume the baud rate 4800 with oscillator frequency 11.0592
MHz.
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 63 / 73
Example -5: Transmission & Reception byte serially
Solution
TH1 = 256 − 2SMOD ×Oscillator Frequency
12×32×Baud Rate
(Assume) SMOD = 0
By putting baud rate 4800, we get
TH1=FAh
Calculate TMOD and SCON
TMOD = 20h
SCON = 50h
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 64 / 73
Example -5: Transmission & Reception byte serially
Assembly Language Program
ORG 0 ; reset address
SJMP START ; jump over reserved area
ORG 40H ; program start address
START: MOV P2, #0FFH ; Port P2 configured as an input port
MOV SCON, #50H ; serial mode 1
MOV TMOD, #20H ; timer 1 mode 2
MOV TH1, #0FAH ; baud rate 19200
SETB TR1 ; turn timer 1 on
MOV DPTR, #MSG ; load pointer for message
TR MSG: CLR A
MOVC A, @A+DPTR ; get the character
JZ READ SW ; check for last character, get out if las
ACALL SEND ; otherwise transfer message serially
INC DPTR ; next character
SJMP TR MSG ; stay in loop until last character is sen
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 65 / 73
Example -5: Transmission & Reception byte serially...
Assembly Language Program
READ SW: MOV A, P2 ; read switches value from port P2
ACALL SEND ; transfer it serially
ACALL RECEV ; get the serial data
MOV P1, A ; display it on LED’s
SJMP READ SW ; repeat the process
SEND: MOV SBUF, A ; load the data into SBUF
HERE: JNB TI, HERE ; stay here till TI set
CLR TI ; clear TI
RET
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 66 / 73
Example -5: Transmission & Reception byte serially...
Assembly Language Program
RECEV: JNB RI, RECEV
MOV A, SBUF
CLR RI
RET
MSG: DB ’Microcontroller is ready’, 0
END ; end of assembly language
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 67 / 73
Example - 6: Switch base Yes - No
Example - 6
Assume a switch is connected to pin P0.3, write an assembly language
program to monitor its status and send two messages to the serial port
continuously as follows:
SW = 0 send “NO”
SW = 1 send “YES”
Assume that crystal frequency of the 8051 is 11.0592 MHz, use 19200 baud
rate and 8 - bit UART. Use SMOD =1
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 68 / 73
Example - 6: Transmission & Reception byte serially
Solution
TH1 = 256 − 2SMOD ×Oscillator Frequency
12×32×Baud Rate
(Given) SMOD = 1
By putting baud rate 19200, we get
TH1=FDh
Calculate TMOD and SCON
TMOD = 20h
SCON = 50h
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 69 / 73
Example - 6: Switch base Yes - No
Assembly Language Program
ORG 0 ; reset address
SJMP START ; jump over reserved area
ORG 40H ; program start address
START: MOV A, PCON
SETB ACC.7
MOV PCON, A
MOV SCON, #50H ; serial mode 1
MOV TMOD, #20H ; timer 1 mode 2
MOV TH1, #0FDH ; baud rate 19200
SETB TR1 ; turn timer 1 on
SETB P0.3 ; make port pin P0.3 as an input port
CHECK: JB P0.3, NEXT
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 70 / 73
Example - 6: Switch base Yes - No...
Assembly Language Program
MOV DPTR, #MSG1 ; If SW = 0 then send message NO
REP1: CLR A
MOVC A, @A+DPTR ; read the message
JZ CHECK ; check for last character
ACALL SEND ; send message serially
INC DPTR ; go for next byte
SJMP REP1
NEXT: MOV DPTR, #MSG2 ; if SW = 1 then send message YES
REP2: CLR A
MOVC A, @A+DPTR ; read the message
JZ CHECK ; check for last character
ACALL SEND ; send message serially
INC DPTR ; go for next byte
SJMP REP2
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 71 / 73
Example - 6: Switch base Yes - No...
Assembly Language Program
SEND: MOV SBUF, A ; copy A into SBUF for serial transmission
HERE: JNB TI, HERE ; stay here till TI set
CLR TI ; clear TI
RET
MSG1: DB ’NO’, 0
MSG2: DB ’YES’, 0
END ; end of assembly language
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 72 / 73
Thank you
Please send your feedback at nbahadure@gmail.com
For more details and updates kindly visit
https://sites.google.com/site/nileshbbahadure/home
Main Slide
Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 73 / 73

More Related Content

What's hot

Microprocessor 8085 complete
Microprocessor 8085 completeMicroprocessor 8085 complete
Microprocessor 8085 complete
Shubham Singh
 
Minimum mode and Maximum mode Configuration in 8086
Minimum mode and Maximum mode Configuration in 8086Minimum mode and Maximum mode Configuration in 8086
Minimum mode and Maximum mode Configuration in 8086
Jismy .K.Jose
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
DominicHendry
 
8051 Microcontroller Notes
8051 Microcontroller Notes8051 Microcontroller Notes
8051 Microcontroller Notes
Dr.YNM
 
8051 Microcontroller I/O ports
8051 Microcontroller I/O ports8051 Microcontroller I/O ports
8051 Microcontroller I/O ports
anishgoel
 
8051 MICROCONTROLLER ARCHITECTURE.pptx
 8051 MICROCONTROLLER ARCHITECTURE.pptx 8051 MICROCONTROLLER ARCHITECTURE.pptx
8051 MICROCONTROLLER ARCHITECTURE.pptx
MemonaMemon1
 
RTC Interfacing and Programming
RTC Interfacing and ProgrammingRTC Interfacing and Programming
RTC Interfacing and Programming
Devashish Raval
 
8086 modes
8086 modes8086 modes
8086 modes
PDFSHARE
 
8051 memory
8051 memory8051 memory
8051 memory
Mayank Garg
 
Arduino- Serial communication
Arduino-  Serial communicationArduino-  Serial communication
Arduino- Serial communication
Jawaher Abdulwahab Fadhil
 
Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051
Jay Patel
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.
parthi_arjun
 
8096 microcontrollers notes
8096 microcontrollers notes8096 microcontrollers notes
8096 microcontrollers notes
Dr.YNM
 
8051 timers
8051 timers8051 timers
Microprocessor & microcontroller
Microprocessor & microcontroller Microprocessor & microcontroller
Microprocessor & microcontroller
Nitesh Kumar
 
Interfacing rs232
Interfacing rs232Interfacing rs232
Interfacing rs232
PRADEEP
 
USART
USARTUSART
Addressing modes
Addressing modesAddressing modes
Addressing modes
karthiga selvaraju
 
Interfacing memory with 8086 microprocessor
Interfacing memory with 8086 microprocessorInterfacing memory with 8086 microprocessor
Interfacing memory with 8086 microprocessor
Vikas Gupta
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051
hello_priti
 

What's hot (20)

Microprocessor 8085 complete
Microprocessor 8085 completeMicroprocessor 8085 complete
Microprocessor 8085 complete
 
Minimum mode and Maximum mode Configuration in 8086
Minimum mode and Maximum mode Configuration in 8086Minimum mode and Maximum mode Configuration in 8086
Minimum mode and Maximum mode Configuration in 8086
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 
8051 Microcontroller Notes
8051 Microcontroller Notes8051 Microcontroller Notes
8051 Microcontroller Notes
 
8051 Microcontroller I/O ports
8051 Microcontroller I/O ports8051 Microcontroller I/O ports
8051 Microcontroller I/O ports
 
8051 MICROCONTROLLER ARCHITECTURE.pptx
 8051 MICROCONTROLLER ARCHITECTURE.pptx 8051 MICROCONTROLLER ARCHITECTURE.pptx
8051 MICROCONTROLLER ARCHITECTURE.pptx
 
RTC Interfacing and Programming
RTC Interfacing and ProgrammingRTC Interfacing and Programming
RTC Interfacing and Programming
 
8086 modes
8086 modes8086 modes
8086 modes
 
8051 memory
8051 memory8051 memory
8051 memory
 
Arduino- Serial communication
Arduino-  Serial communicationArduino-  Serial communication
Arduino- Serial communication
 
Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.
 
8096 microcontrollers notes
8096 microcontrollers notes8096 microcontrollers notes
8096 microcontrollers notes
 
8051 timers
8051 timers8051 timers
8051 timers
 
Microprocessor & microcontroller
Microprocessor & microcontroller Microprocessor & microcontroller
Microprocessor & microcontroller
 
Interfacing rs232
Interfacing rs232Interfacing rs232
Interfacing rs232
 
USART
USARTUSART
USART
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Interfacing memory with 8086 microprocessor
Interfacing memory with 8086 microprocessorInterfacing memory with 8086 microprocessor
Interfacing memory with 8086 microprocessor
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051
 

Similar to Serial communication of microcontroller 8051

MODELLING AND SIMULATION OF 128-BIT CROSSBAR SWITCH FOR NETWORK -ONCHIP
MODELLING AND SIMULATION OF 128-BIT CROSSBAR SWITCH FOR NETWORK -ONCHIPMODELLING AND SIMULATION OF 128-BIT CROSSBAR SWITCH FOR NETWORK -ONCHIP
MODELLING AND SIMULATION OF 128-BIT CROSSBAR SWITCH FOR NETWORK -ONCHIP
VLSICS Design
 
DATA TRANSMISSION, Synchronous & Asynchronous Data Transfer
DATA TRANSMISSION, Synchronous & Asynchronous Data TransferDATA TRANSMISSION, Synchronous & Asynchronous Data Transfer
DATA TRANSMISSION, Synchronous & Asynchronous Data Transfer
Jabbar Tunyo
 
Design and implementation of uart on soc
Design and implementation of uart on socDesign and implementation of uart on soc
Design and implementation of uart on soc
Ijrdt Journal
 
Giga bit per second Differential Scheme for High Speed Interconnect
Giga bit per second Differential Scheme for High Speed InterconnectGiga bit per second Differential Scheme for High Speed Interconnect
Giga bit per second Differential Scheme for High Speed Interconnect
VLSICS Design
 
data transmission
data transmission data transmission
data transmission
Sadaf Rasheed
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)
ijceronline
 
serial-200505101453.pdf
serial-200505101453.pdfserial-200505101453.pdf
serial-200505101453.pdf
KiranG731731
 
io intweface.pptx
io intweface.pptxio intweface.pptx
io intweface.pptx
SureshMahar2
 
OSI MODELS.pptx
OSI  MODELS.pptxOSI  MODELS.pptx
OSI MODELS.pptx
DeepakChaudhary373615
 
Verification of uart ip core using uvm
Verification of uart ip core using uvmVerification of uart ip core using uvm
Verification of uart ip core using uvm
eSAT Publishing House
 
Codec Scheme for Power Optimization in VLSI Interconnects
Codec Scheme for Power Optimization in VLSI InterconnectsCodec Scheme for Power Optimization in VLSI Interconnects
Codec Scheme for Power Optimization in VLSI Interconnects
IJEEE
 
Introduction to Computer Networking and Types
Introduction to Computer Networking and TypesIntroduction to Computer Networking and Types
Introduction to Computer Networking and Types
Prof Ansari
 
Serial Port Device Driver
Serial Port Device DriverSerial Port Device Driver
Serial Port Device Driver
Emblogic
 
An approach to Measure Transition Density of Binary Sequences for X-filling b...
An approach to Measure Transition Density of Binary Sequences for X-filling b...An approach to Measure Transition Density of Binary Sequences for X-filling b...
An approach to Measure Transition Density of Binary Sequences for X-filling b...
IJECEIAES
 
UART project report by Tarun Khaneja ( 09034406598 )
UART project report by Tarun Khaneja ( 09034406598 )UART project report by Tarun Khaneja ( 09034406598 )
UART project report by Tarun Khaneja ( 09034406598 )
Tarun Khaneja
 
Hands On Data Communications, Networking and TCP/IP Troubleshooting
Hands On Data Communications, Networking and TCP/IP TroubleshootingHands On Data Communications, Networking and TCP/IP Troubleshooting
Hands On Data Communications, Networking and TCP/IP Troubleshooting
Living Online
 
Universal Serial Communication Interface
Universal Serial Communication InterfaceUniversal Serial Communication Interface
Universal Serial Communication Interface
Sandesh Agrawal
 
Serial Communication Interface with Error Detection
Serial Communication Interface with Error DetectionSerial Communication Interface with Error Detection
Serial Communication Interface with Error Detection
iosrjce
 
M010617376
M010617376M010617376
M010617376
IOSR Journals
 
zxwr-rnc-dimensioning-35-pdf
zxwr-rnc-dimensioning-35-pdfzxwr-rnc-dimensioning-35-pdf
zxwr-rnc-dimensioning-35-pdf
amini110
 

Similar to Serial communication of microcontroller 8051 (20)

MODELLING AND SIMULATION OF 128-BIT CROSSBAR SWITCH FOR NETWORK -ONCHIP
MODELLING AND SIMULATION OF 128-BIT CROSSBAR SWITCH FOR NETWORK -ONCHIPMODELLING AND SIMULATION OF 128-BIT CROSSBAR SWITCH FOR NETWORK -ONCHIP
MODELLING AND SIMULATION OF 128-BIT CROSSBAR SWITCH FOR NETWORK -ONCHIP
 
DATA TRANSMISSION, Synchronous & Asynchronous Data Transfer
DATA TRANSMISSION, Synchronous & Asynchronous Data TransferDATA TRANSMISSION, Synchronous & Asynchronous Data Transfer
DATA TRANSMISSION, Synchronous & Asynchronous Data Transfer
 
Design and implementation of uart on soc
Design and implementation of uart on socDesign and implementation of uart on soc
Design and implementation of uart on soc
 
Giga bit per second Differential Scheme for High Speed Interconnect
Giga bit per second Differential Scheme for High Speed InterconnectGiga bit per second Differential Scheme for High Speed Interconnect
Giga bit per second Differential Scheme for High Speed Interconnect
 
data transmission
data transmission data transmission
data transmission
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)
 
serial-200505101453.pdf
serial-200505101453.pdfserial-200505101453.pdf
serial-200505101453.pdf
 
io intweface.pptx
io intweface.pptxio intweface.pptx
io intweface.pptx
 
OSI MODELS.pptx
OSI  MODELS.pptxOSI  MODELS.pptx
OSI MODELS.pptx
 
Verification of uart ip core using uvm
Verification of uart ip core using uvmVerification of uart ip core using uvm
Verification of uart ip core using uvm
 
Codec Scheme for Power Optimization in VLSI Interconnects
Codec Scheme for Power Optimization in VLSI InterconnectsCodec Scheme for Power Optimization in VLSI Interconnects
Codec Scheme for Power Optimization in VLSI Interconnects
 
Introduction to Computer Networking and Types
Introduction to Computer Networking and TypesIntroduction to Computer Networking and Types
Introduction to Computer Networking and Types
 
Serial Port Device Driver
Serial Port Device DriverSerial Port Device Driver
Serial Port Device Driver
 
An approach to Measure Transition Density of Binary Sequences for X-filling b...
An approach to Measure Transition Density of Binary Sequences for X-filling b...An approach to Measure Transition Density of Binary Sequences for X-filling b...
An approach to Measure Transition Density of Binary Sequences for X-filling b...
 
UART project report by Tarun Khaneja ( 09034406598 )
UART project report by Tarun Khaneja ( 09034406598 )UART project report by Tarun Khaneja ( 09034406598 )
UART project report by Tarun Khaneja ( 09034406598 )
 
Hands On Data Communications, Networking and TCP/IP Troubleshooting
Hands On Data Communications, Networking and TCP/IP TroubleshootingHands On Data Communications, Networking and TCP/IP Troubleshooting
Hands On Data Communications, Networking and TCP/IP Troubleshooting
 
Universal Serial Communication Interface
Universal Serial Communication InterfaceUniversal Serial Communication Interface
Universal Serial Communication Interface
 
Serial Communication Interface with Error Detection
Serial Communication Interface with Error DetectionSerial Communication Interface with Error Detection
Serial Communication Interface with Error Detection
 
M010617376
M010617376M010617376
M010617376
 
zxwr-rnc-dimensioning-35-pdf
zxwr-rnc-dimensioning-35-pdfzxwr-rnc-dimensioning-35-pdf
zxwr-rnc-dimensioning-35-pdf
 

More from Nilesh Bhaskarrao Bahadure

Biomedical Signal Origin and Dynamics
Biomedical Signal Origin and DynamicsBiomedical Signal Origin and Dynamics
Biomedical Signal Origin and Dynamics
Nilesh Bhaskarrao Bahadure
 
Introduction to Medical Image Processing
Introduction to Medical Image ProcessingIntroduction to Medical Image Processing
Introduction to Medical Image Processing
Nilesh Bhaskarrao Bahadure
 
Timing diagram of microprocessor 8085
Timing diagram of microprocessor 8085Timing diagram of microprocessor 8085
Timing diagram of microprocessor 8085
Nilesh Bhaskarrao Bahadure
 
Timers and counters of microcontroller 8051
Timers and counters of microcontroller 8051Timers and counters of microcontroller 8051
Timers and counters of microcontroller 8051
Nilesh Bhaskarrao Bahadure
 
Peripherals of Microprocessor 8085
Peripherals of Microprocessor 8085Peripherals of Microprocessor 8085
Peripherals of Microprocessor 8085
Nilesh Bhaskarrao Bahadure
 
Microprocessor 8085 Basics
Microprocessor 8085 BasicsMicroprocessor 8085 Basics
Microprocessor 8085 Basics
Nilesh Bhaskarrao Bahadure
 
Microcontroller 8051 instruction set and assemble directives
Microcontroller 8051 instruction set and assemble directivesMicrocontroller 8051 instruction set and assemble directives
Microcontroller 8051 instruction set and assemble directives
Nilesh Bhaskarrao Bahadure
 
Microcontroller 8051 basics (part I)
Microcontroller 8051 basics (part I)Microcontroller 8051 basics (part I)
Microcontroller 8051 basics (part I)
Nilesh Bhaskarrao Bahadure
 
Memory interfacing of microprocessor 8085
Memory interfacing of microprocessor 8085Memory interfacing of microprocessor 8085
Memory interfacing of microprocessor 8085
Nilesh Bhaskarrao Bahadure
 
Memory interfacing of microcontroller 8051
Memory interfacing of microcontroller 8051Memory interfacing of microcontroller 8051
Memory interfacing of microcontroller 8051
Nilesh Bhaskarrao Bahadure
 
Interrupts of microprocessor 8085
Interrupts of microprocessor 8085Interrupts of microprocessor 8085
Interrupts of microprocessor 8085
Nilesh Bhaskarrao Bahadure
 
Interrupts of microcontroller 8051
Interrupts of microcontroller 8051Interrupts of microcontroller 8051
Interrupts of microcontroller 8051
Nilesh Bhaskarrao Bahadure
 
Instruction sets of microprocessor 8085
Instruction sets of microprocessor 8085Instruction sets of microprocessor 8085
Instruction sets of microprocessor 8085
Nilesh Bhaskarrao Bahadure
 
Embedded Systems
Embedded Systems Embedded Systems
Embedded Systems
Nilesh Bhaskarrao Bahadure
 
Basic Electronics Semiconductor Diodes
Basic Electronics Semiconductor DiodesBasic Electronics Semiconductor Diodes
Basic Electronics Semiconductor Diodes
Nilesh Bhaskarrao Bahadure
 
Basic Electronics Electrical Transducers
Basic Electronics Electrical TransducersBasic Electronics Electrical Transducers
Basic Electronics Electrical Transducers
Nilesh Bhaskarrao Bahadure
 
Basic Electronics BJT
Basic Electronics BJTBasic Electronics BJT
Basic Electronics BJT
Nilesh Bhaskarrao Bahadure
 
Applications of Microcontroller 8051
Applications of Microcontroller 8051Applications of Microcontroller 8051
Applications of Microcontroller 8051
Nilesh Bhaskarrao Bahadure
 
Question Bank Programmable Logic Controller
Question Bank Programmable Logic ControllerQuestion Bank Programmable Logic Controller
Question Bank Programmable Logic Controller
Nilesh Bhaskarrao Bahadure
 
Question Bank Microprocessor 8085
Question Bank Microprocessor 8085Question Bank Microprocessor 8085
Question Bank Microprocessor 8085
Nilesh Bhaskarrao Bahadure
 

More from Nilesh Bhaskarrao Bahadure (20)

Biomedical Signal Origin and Dynamics
Biomedical Signal Origin and DynamicsBiomedical Signal Origin and Dynamics
Biomedical Signal Origin and Dynamics
 
Introduction to Medical Image Processing
Introduction to Medical Image ProcessingIntroduction to Medical Image Processing
Introduction to Medical Image Processing
 
Timing diagram of microprocessor 8085
Timing diagram of microprocessor 8085Timing diagram of microprocessor 8085
Timing diagram of microprocessor 8085
 
Timers and counters of microcontroller 8051
Timers and counters of microcontroller 8051Timers and counters of microcontroller 8051
Timers and counters of microcontroller 8051
 
Peripherals of Microprocessor 8085
Peripherals of Microprocessor 8085Peripherals of Microprocessor 8085
Peripherals of Microprocessor 8085
 
Microprocessor 8085 Basics
Microprocessor 8085 BasicsMicroprocessor 8085 Basics
Microprocessor 8085 Basics
 
Microcontroller 8051 instruction set and assemble directives
Microcontroller 8051 instruction set and assemble directivesMicrocontroller 8051 instruction set and assemble directives
Microcontroller 8051 instruction set and assemble directives
 
Microcontroller 8051 basics (part I)
Microcontroller 8051 basics (part I)Microcontroller 8051 basics (part I)
Microcontroller 8051 basics (part I)
 
Memory interfacing of microprocessor 8085
Memory interfacing of microprocessor 8085Memory interfacing of microprocessor 8085
Memory interfacing of microprocessor 8085
 
Memory interfacing of microcontroller 8051
Memory interfacing of microcontroller 8051Memory interfacing of microcontroller 8051
Memory interfacing of microcontroller 8051
 
Interrupts of microprocessor 8085
Interrupts of microprocessor 8085Interrupts of microprocessor 8085
Interrupts of microprocessor 8085
 
Interrupts of microcontroller 8051
Interrupts of microcontroller 8051Interrupts of microcontroller 8051
Interrupts of microcontroller 8051
 
Instruction sets of microprocessor 8085
Instruction sets of microprocessor 8085Instruction sets of microprocessor 8085
Instruction sets of microprocessor 8085
 
Embedded Systems
Embedded Systems Embedded Systems
Embedded Systems
 
Basic Electronics Semiconductor Diodes
Basic Electronics Semiconductor DiodesBasic Electronics Semiconductor Diodes
Basic Electronics Semiconductor Diodes
 
Basic Electronics Electrical Transducers
Basic Electronics Electrical TransducersBasic Electronics Electrical Transducers
Basic Electronics Electrical Transducers
 
Basic Electronics BJT
Basic Electronics BJTBasic Electronics BJT
Basic Electronics BJT
 
Applications of Microcontroller 8051
Applications of Microcontroller 8051Applications of Microcontroller 8051
Applications of Microcontroller 8051
 
Question Bank Programmable Logic Controller
Question Bank Programmable Logic ControllerQuestion Bank Programmable Logic Controller
Question Bank Programmable Logic Controller
 
Question Bank Microprocessor 8085
Question Bank Microprocessor 8085Question Bank Microprocessor 8085
Question Bank Microprocessor 8085
 

Recently uploaded

KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball playEric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
enizeyimana36
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 

Recently uploaded (20)

KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball playEric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 

Serial communication of microcontroller 8051

  • 1. Serial Communication of 8051 Microcontroller Dr. Nilesh Bhaskarrao Bahadure https://www.sites.google.com/site/nileshbbahadure/home July 25, 2021 Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 1 / 73
  • 2. Overview I 1 Universal Asynchronous Receiver Transmitter (UART) 2 Introduction to Serial Communication 3 Types of Transmission Simplex Communication Duplex Communication Half Duplex Communication Full Duplex Communication 4 Methods of Serial data Transmission Synchronous serial data transfer Asynchronous serial data transfer Differences Synchronous Asynchronous 5 Data Transfer Rate 6 Calculation of Baud Rate 7 SCON Register Importance of TI Flag Bit Importance of RI Flag Bit Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 2 / 73
  • 3. Overview II 8 SBUF Register 9 Writing to the Serial port 10 Reading the Serial port 11 PCON Register 12 Programming of transmission byte serially 13 Programming of reception of byte serially 14 Examples Example -1: Transmission of N Example -2: Transmission of N Example -3: Receive byte serially Example -4: Transmission of multiple byte serially Example -5: Transmission & Reception byte serially Example - 6: Switch base Yes - No Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 3 / 73
  • 4. Universal Asynchronous Receiver Transmitter (UART) UARTs are used for serial communication between systems; they can be either half duplex (send or receive but at different intervals) or full duplex (send and receive at the same time). Also known as an RS232 connection the microcontroller UART can provide the connection with a PC or another Microcontroller-based system. Figure 1 illustrates possible connection ar- rangements. In a minimum connection there could be only two transmission lines, transmit (Tx) and receive (Rx) as shown in Figure 2. The data is con- veyed as a bit stream, either transmit or receive, and the speed is defined by the baud rate i.e. the bits per second. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 4 / 73
  • 5. Universal Asynchronous Receiver Transmitter (UART)... Figure : Use of RS232 interface between PC and Microcontroller or between two microcontrollers Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 5 / 73
  • 6. Universal Asynchronous Receiver Transmitter (UART)... Figure : RS 232 transmit (Tx) and Receive (Rx) connections between a PC and Microcontroller Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 6 / 73
  • 7. Universal Asynchronous Receiver Transmitter (UART)... The UART has four modes of operation, 0 to 3. Modes 0 and 2 have fixed baud rates, mode 0 is one-sixth of the oscillator frequency, and mode 2 is 1/16 or 1/32 of the oscillator frequency. For modes 1 and 3 the baud rate can be selected, a typical range is: 75; 150; 300; 600; 1200; 2400; 4800; 9600; 19200; 38400 Modes 0 and 1 are used for connection between two devices. Modes 2 and 3 are used for master slave multiprocessor systems, in principle there could be one master microcontroller and up to 255 slave microcontrollers. In mode 1 ten bits are used to specify an RS232 frame consisting of 1 start bit (logic 0), 8 data bits and 1 stop bit (logic 1). For example the ASCII bit pattern 0100 0001 (hex 41) represents the character ’A’ and is transmitted as shown in Figure 3; least significant bit (LSB) first. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 7 / 73
  • 8. Universal Asynchronous Receiver Transmitter (UART)... Figure : ASCII bit pattern 01000001 (41h) for character ’A’ Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 8 / 73
  • 9. Introduction to Serial Communication One of the 8051s most powerful features is its integrated UART, otherwise known as a serial port. The fact that the 8051 has an integrated serial port means that you may very easily read and write values to the serial port. If it were not for the integrated serial port, writing a byte to a serial line would be a rather complicated process requiring turning ON and OFF one of the I/O lines in rapid succession to properly “clock out” each individual bit, including start bits, stop bits, and parity bits. Actually, if the serial communication port is not integrated within the chip then proper synchronization between the transmitter and the receiver is very complicated process. However, we do not have to do this. Instead, we simply need to configure the serial ports operation mode and baud rate. This configuration can be done by writing very simple code, may requires only 5 to 8 lines of code. Once configured, all we have to do is write to an SFR to write a value to the serial port or read the same SFR to read a value from the serial port. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 9 / 73
  • 10. Types of Transmission Serial communication is capable of processing or transmitting of information by 2 types they are Simplex communication and Duplex communication. Further the duplex communication is also of 2 types, they are, half duplex communication and full duplex communication. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 10 / 73
  • 11. Simplex Communication In the simplex communication, the serial data is transmitted only in one direction, i.e. from transmitter to receiver. The simplex is a one way transmission, data is transferred only in one di- rection over a single communication channel. For example Microprocessor transmit data to the Printer, Microprocessor transmit data to the CRT dis- play unit. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 11 / 73
  • 12. Simplex Communication... Figure : Simplex Transmission Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 12 / 73
  • 13. Duplex Communication The Duplex is a two way transmission; data may be transferred between two transceivers in both directions simultaneously. So it will contain one way transmission or two way transmission at a time. For example Telephone line. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 13 / 73
  • 14. Half Duplex Communication The Half Duplex is a two way transmission but in such a way that data may travel in only one direction at a time. For example Wacky Talky (Wireless System). Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 14 / 73
  • 15. Full Duplex Communication The full duplex is a two way transmission (communication) but in such a way that the data may travel in both the direction at the same time. For example Telephone line, mobile communication etc. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 15 / 73
  • 16. Duplex Communication... Figure : Duplex Transmission Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 16 / 73
  • 17. Methods of Serial data Transmission / Format of serial data transmission In modern data communication system for the data transfer two types of format are used Synchronous and Asynchronous. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 17 / 73
  • 18. Synchronous serial data transfer In this method block of data bytes are transferred serially at a time. The numbers of data bytes are not limited. The data bytes are transferred one after the other and so on up to the end. In this method at the starting of data transfer, first transfer synchronous characters one synchronous char- acter is compulsory for the data transfer and 2nd is optional. Synchronous characters are inform to the receiver will start the transferring of data i.e. its provide synchronization between transmitter and receiver. In one syn- chronous character 256 receivers are connected i.e. from 00 to FFh. As the synchronization is done only once and before the start of data transfer, the synchronous communication is faster compared to asynchronous com- munication. So it is generally used for fast data transfer at high rate. The synchronous data format with two synchronous characters is shown in the figure 6 Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 18 / 73
  • 19. Synchronous serial data transfer Figure : Synchronous data format Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 19 / 73
  • 20. Asynchronous serial data transfer In this method block of data bytes are transferred serially at a time. The numbers of data bytes are not limited. The data bytes are transferred one after the other and so on up to the end. In this method at the starting of data transfer, first transfer synchronous characters one synchronous char- acter is compulsory for the data transfer and 2nd is optional. Synchronous characters are inform to the receiver will start the transferring of data i.e. its provide synchronization between transmitter and receiver. In one syn- chronous character 256 receivers are connected i.e. from 00 to FFh. As the synchronization is done only once and before the start of data transfer, the synchronous communication is faster compared to asynchronous com- munication. So it is generally used for fast data transfer at high rate. The synchronous data format with two synchronous characters is shown in the figure 7 Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 20 / 73
  • 21. Asynchronous serial data transfer Figure : Asynchronous data format Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 21 / 73
  • 22. Differences Between Synchronous & Asynchronous Data Transfer Synchronous data transfer Asynchronous data transfer It is used to transfer a group of Characters at a time. It is used to transfer one char- acter at a time Used for high data transfer rates 20 K bits / second Used for data transfer rates 20 K bits / second Synchronous character are transmitted along with the group of characters Synchronous characters are not transmitted along with the characters No start and stop bits for each character is used Start and stop bit for each char- acter is present which forms a frame Table : Differences Syn Asynch Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 22 / 73
  • 23. Differences Between Synchronous & Asynchronous Data Transfer... Synchronous data transfer Asynchronous data transfer One clock is used for both transmitter and receiver Two separate clock inputs can be used for transmitter and re- ceiver Since synchronization is in- volved, this can be imple- mented by using hardware only No synchronization is required hence hardware and software implementation is possible. Table : Differences Syn Asynch Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 23 / 73
  • 24. Data Transfer Rate / Baud Rate Data transfer rate is defined as the number of bits are transmitted or re- ceived in one second. Usually it is referred as bits per second (BPS) and sometimes it is also called baud rate (BR). Transmission of the serial data requires configuring baud rate, actually at the baud rate it was defines that how many bits to be transferred in one second. It is not possible to con- figure data transfer serially without configuring baud rate. It is important to note that, it is not necessary that bits per second and baud rate are same. Because the baud rate is used in reference to MODEM (Modulator - Demodulator), where number of signal changes indicate bits transmission and in single signal change may indicate more data bits are transmitted, whereas if conductor based transmission is concerned then bits per second and baud rate are same. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 24 / 73
  • 25. Data Transfer Rate / Baud Rate... Baud rate in 8051 Microcontroller is programmable, means that different baud rates can be easily achieved without any hardware configuration or modifications; this is simply done by writing a set of instructions. The 8051 Microcontroller divides crystal frequency by 12 to get the machine cycle frequency, in other words we say that internal frequency is the 1/12th of crystal frequency (External frequency). Serial communication UART circuitry once again divides this frequency i.e. machine cycle frequency by 32 or 16, depending on the status of SMOD bit in the PCON register to use by timer 1 to generate baud rate. in other words we may say that on chip UART circuitry uses the frequency after diving the machine cycle frequency by 32 or 16 for calculation of baud rate. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 25 / 73
  • 26. Data Transfer Rate / Baud Rate... Figure : Setting baud rate for SMOD =0 Figure : Setting baud rate for SMOD =1 Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 26 / 73
  • 27. Data Transfer Rate / Baud Rate... To set baud rate compatible with IBM PCs timer 1 must be operated in auto reload mode. The reason behind to use the auto reload mode is that, it is possible to get maximum overflows (ticks) at very high rate only in auto reload mode. The values to be loaded in TH1 register and their corresponding baud rate compatible with IBM PCs are shown in the table 3 Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 27 / 73
  • 28. Data Transfer Rate / Baud Rate... TH1 (Decimal) TH1 (Hex) Baud Rate -3 FDh 9600 -6 FAh 4800 -12 F4h 2400 -24 E8h 1200 -48 D0h 600 Table : Timer 1 TH1 Register Value for the Baud Rate Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 28 / 73
  • 29. Calculation of Baud Rate In mode 1 and 3, the baud rate is determined by how frequently timer 1 overflows. The more frequently timer 1 overflows, the higher the baud rate i.e. how fast the timer flag bit overflows that decides baud rate. In other words we can say that baud rate is directly related with timer flag rollover. There are many ways one can cause timer 1 to overflow at a rate that determines a baud rate but the most common method is to put timer 1 in 8 - bit auto - reload mode (timer mode 2) and set a reload value (TH1) that causes timer 1 to overflow at a frequency appropriate to generate a baud rate. To determine the value that must be loaded in TH1 register to generate a given baud rate, we may use the following equation: Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 29 / 73
  • 30. Calculation of Baud Rate... TH1 = 256 − 2SMOD ×Oscillator Frequency 12×32×Baud Rate TH1 = 256 − 2SMOD ×Oscillator Frequency 384×Baud Rate if SMOD = 0 TH1 = 256 − Oscillator Frequency 384×Baud Rate if SMOD = 1 TH1 = 256 − Oscillator Frequency 192×Baud Rate Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 30 / 73
  • 31. SCON Register D7 D6 D5 D4 D3 D2 D1 D0 SM0 SM1 SM2 REN TB8 RB8 TI RI Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 31 / 73
  • 32. SCON Register... Bit Name Bit address Function 7 SM0 9Fh Serial port mode bit 0 6 SM1 9Eh Serial port mode bit 1 5 SM2 9Dh Multiprocessor communication enable bit 4 REN 9Ch Receiver enables. This bit must be set in order to receive char- acters serially. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 32 / 73
  • 33. SCON Register... Bit Name Bit address Function 3 TB8 9Bh Transmit bit 8. The 9th bit to transmit in mode 2 and mode 3 2 RB8 9Ah Receive bit 8. The 9th bit re- ceived in mode 2 and mode 3 1 TI 99h Transmit flag. Set when a byte has been transmitted com- pletely. 0 RI 98h Receive flag. Set when a byte has been received completely. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 33 / 73
  • 34. SCON Register... SM0 SM1 Serial mode Explanation Baud rate 0 0 0 8 - bit shift register Oscillator/12 0 1 1 8 - bit UART Set by timer 1 1 0 2 9 - bit UART Oscillator/32 1 1 3 9 - bit UART Set by timer 1 Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 34 / 73
  • 35. Importance of TI Flag Bit The following steps are observed when the character byte transferred serially via TxD line 1. The start bit is transmitted; indicate that data transmitted is going to be start. 2. The 8 - bit main value of the character byte start transmission with LSB (bit D0) first. 3. The stop bit is transmitted. The stop bit is the last bit to be transmitted if the parity bit is not considered. It is during the transmission of stop bit, TI flag bit is raised to one (logic high) by CPU, indicating that transmission is completed. So 8051 is ready to transfer a new character byte. 4. By monitoring TI flag bit we ensure that the previous byte is transmitted completely or not. Suppose TI flag bit doesn’t raises and we are trying to send new character, so there may be chances that some bits of the previous byte are lost and new character gets transmitted. In other words TI flag bit is raised by CPU in order to ensure proper transmission of data bits. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 35 / 73
  • 36. Importance of TI Flag Bit.. 5. When TI rises it must be forced to zero by software program in order to transmit next character or byte. From the above points it is clear that when 8051 Microcontroller finishes transmission, it will raise TI flag bit automatically, gives the information that transmission is completed in all respects. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 36 / 73
  • 37. Importance of RI Flag Bit In receiving bits via its RxD line, the 8051 Microcontroller goes through the following steps 1. It receives the start bit, indicating that the next bit is the first bit of the character byte it is about to receive. 2. The 8 - bit character is received one bit at a time, The LSB i.e. D0 bit receives first. When the last bit (bit D7) is received, a byte is formed and placed in the SBUF register. 3. The stop bit is received, when receiving the stop bit the 8051 makes RI = 1, indicating that an entire character byte has been received and must be picked up before it gets over written by an incoming character. 4. By checking the RI flag bit when it is raised, we know that the character has been received and it is available in the SBUF register. We must copy the SBUF register contents to a safe place in some other register or in memory before it is lost. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 37 / 73
  • 38. Importance of RI Flag Bit... 5. After the SBUF contents are copied into a safe place, the RI flag bit must be forced to 0 by the software instruction CLR RI in order to allow the next received character byte to be placed in SBUF, failure to do this causes loss of the received character. From the above, we conclude that by checking the RI flag bit, we know whether or not the 8051 has received a character byte. If we fail to copy SBUF into a safe place, we risk the loss of the received byte. More impor- tantly, it must be noted that RI flag bit is raised by the 8051, but it must be cleared by the programmer with an instruction such as CLR RI. It must also be noted that if we copy SBUF into a safe place before the RI flag bit is raised, we risk copying the garbage. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 38 / 73
  • 39. SBUF Register The SBUF register is used to load the data to be transmitted serially. The data received serially by 8051 Microcontroller is also copied to the SBUF register. The ON chip address of SBUF register is 99h. The SBUF register is also access like any other register of 8051 Microcontroller for example, to load data 34h to the SBUF register then, it may written as MOV SBUF, #34h or MOV 99h, #34h Similarly the data from SBUF register is copied to any other register, for example MOV A, SBUF Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 39 / 73
  • 40. Writing to the serial port Once the Serial Port has been properly configured as explained above, the serial port is ready to be used to send data and receive data. If you thought that configuring the serial port was simple, using the serial port will be a breeze. To write a byte to the serial port one must simply write the value to the SBUF (99h) SFR. For Example, if you wanted to send the letter “A” to the serial port, it could be accomplished as easily as: MOV SBUF, #’A’ Upon execution of the above instruction the 8051 will begin transmitting the character via the serial port. Obviously transmission is not instantaneous–it takes a measureable amount of time to transmit Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 40 / 73
  • 41. Writing to the serial port The 8051 lets us know when it is done transmitting a character by setting the TI bit in SCON. When this bit is set we know that the last character has been transmitted and that we may send the next character, if any. Consider the following code segment: CLR TI ; be sure the bit is initially clear MOV SBUF, #’A’ ; Send the letter A to the serial port JNB TI, $ ; Pause until the RI bit is set. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 41 / 73
  • 42. Reading the serial port Reading data received by the serial port is equally easy. To read a byte from the serial port one just needs to read the value stored in the SBUF (99h) SFR after the 8051 has automatically set the RI flag in SCON. For example, if your program wants to wait for a character to be received and subsequently read it into the Accumulator, the following code segment may be used: JNB RI, $ ; Wait for the 8051 to set the RI flag MOV A, SBUF ; Read the character from the serial port Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 42 / 73
  • 43. PCON Register Question Explain how to double the baud rate without changing crystal frequency D7 D6 D5 D4 D3 D2 D1 D0 SMOD – – – GF1 GF0 PD IDL Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 43 / 73
  • 44. PCON Register... There are two ways to increase the baud rate of data transfer in the 8051 Microcontroller 1. Use a higher frequency crystal 2. Change a bit in the PCON register, i.e. bit D7 (SMOD) bit of PCON register When the 8051 is powered up, D7 bit of the PCON register is zero, we can set this bit to HIGH by software and thereby double the baud rate. The following sequence of the instructions must be used to set bit D7 HIGH of the PCON register, since PCON is not a bit addressable register. There may be more methods to set SMOD = 1, without affecting the other bits of PCON register, so one may use any sequence of the program with ensuring that the other bits of the PCON register is unaffected and only SMOD gets high. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 44 / 73
  • 45. PCON Register... MOV A, PCON ; get original or old value of PCON register in Accumulator SETB ACC.7 ; make D7 (SMOD) = 1 MOV PCON, A ; now SMOD = 1 without modifying other bits of the PCON register Alternatively, MOV A, PCON ; get original or old value of PCON register in Accumulator OR A, #0FFh ; make D7 (SMOD) = 1 MOV PCON, A ; now SMOD = 1 without modifying other bits of the PCON register Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 45 / 73
  • 46. Calculation of Baud Rate... TH1 = 256 − 2SMOD ×Oscillator Frequency 12×32×Baud Rate TH1 = 256 − 2SMOD ×Oscillator Frequency 384×Baud Rate if SMOD = 0 TH1 = 256 − Oscillator Frequency 384×Baud Rate if SMOD = 1 TH1 = 256 − Oscillator Frequency 192×Baud Rate Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 46 / 73
  • 47. Baud rate comparision for SMOD = 0 & SMOD = 1 Baud rate comparisons for SMOD = 0 and SMOD =1 is shown in the table below. It shows that the for the same value of TH1, the baud rate are doubled when SMOD = 1 TH1 (Decimal) TH1 (Hex) Baud Rate SMOD = 0 SMOD = 1 -3 FDh 9600 19200 -6 FAh 4800 9600 -12 F4h 2400 4800 -24 E8h 1200 2400 -48 D0h 600 1200 Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 47 / 73
  • 48. Programming of transmission byte serially The following steps are taken to transmit a character or byte serially through the TxD line of 8051 Microcontroller. 1. The TMOD register must be initialized with 20h indicating that timer 1 in auto - reload mode (mode 2), to set the baud rate. The baud rate is configured only using auto - reload mode, because only in auto - reload mode it is possible to get maximum overflow at very high rate. 2. Load TH1 register with a value corresponding to the specified baud rate. 3. Initialize SCON register with value 50h indicating serial mode 1 i.e. 8 - bit data, 1 start bit and 1 stop bit. In most of the system use only serial mode 1, because this mode is IBM compatible. 4. Set TR1 = 1 to start the timer 1, to get the baud rate. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 48 / 73
  • 49. Programming of transmission byte serially... 5. The character byte to be transmitted serially must be put in the SBUF register. 6. Keep monitoring TI (transmitter interrupt) flag bit using the instruction “CHECK: JNB TI, CHECK”, in order to ensure that transmission is com- pleted or not. When TI rises, indicates completion of the transmission of character them go out of the loop. 7. Clear TI flag bit using instruction CLR TI 8. In order to repeat the process, i.e. to transmit another character or byte go to step 5. No need to start the timer again, as once the baud rate is configured; it is available throughout the completion of the program. The baud rate is change again by loading another value in TH1 register and start the timer or it may gets laps by resetting the system. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 49 / 73
  • 50. Programming of reception of byte serially The following steps are followed to receive character or byte serially through the RxD line of 8051 Microcontroller. 1. The TMOD register must be initialized with 20h indicating that timer 1 in auto - reload mode (mode 2), to set the baud rate. The baud rate is configured only using auto - reload mode, because only in auto - reload mode it is possible to get maximum overflow at very high rate. 2. Load TH1 register with a value corresponding to the specified baud rate. 3. Initialize SCON register with value 50h indicating serial mode 1 i.e. 8 - bit data, 1 start bit and 1 stop bit. In most of the system use only serial mode 1, because this mode is IBM compatible. 4. Set TR1 = 1 to start the timer 1, to get the baud rate. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 50 / 73
  • 51. Programming of reception of byte serially... 5. Keep monitoring RI (receiver interrupt) flag bit using the instruction “CHECK: JNB RI, CHECK”, in order to ensure that reception is completed or not. When RI rises, indicates completion of the reception of character then go out of the loop. 6. When RI flag bit is rises then there is a byte i.e. received byte in SBUF register, so it must be picked up before a new incoming character is received. In other words when RI is rises then store the SBUF contents in safe place. 7. Clear RI flag bit using instruction CLR RI 8. In order to repeat the process, i.e. to receive another character or byte go to step 5. No need to start the timer again, as once the baud rate is configured; it is available throughout the completion of the program. The baud rate is change again by loading another value in TH1 register and start the timer or it may gets laps by resetting the system. Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 51 / 73
  • 52. Example -1: Transmission of character N serially Example - 1 8051 Microcontroller has an oscillator frequency of 11.0592MHz. Using timer 1 and configuring the UART in mode 1 write an assembly language program that transmits the ASCII character “N” at a baud rate of 9600. Solution TH1 = 256 − 2SMOD ×Oscillator Frequency 12×32×Baud Rate (Assume) SMOD = 0 By putting baud rate 9600, we get TH1=FDh Calculate TMOD and SCON TMOD = 20h SCON = 50h Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 52 / 73
  • 53. Example -1: Transmission of character N serially Assembly Language Program ORG 0 ; reset address SJMP START ; jump over reserved area ORG 40H ; program start address START: MOV SCON, #50H ; serial mode 1 MOV TMOD, #20H ; timer 1 mode 2 MOV TH1, #0FDH ; baud rate 9600 SETB TR1 ; turn timer 1 on AGAIN: MOV SBUF, #’N’ ; ASCII of N into SBUF HERE: JNB TI, HERE ; stay here till TI is set CLR TI ; clear TI SJMP AGAIN ; repeat END ; end of assembly language Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 53 / 73
  • 54. Example -2: Transmission of character N serially Example - 2 8051 Microcontroller has an oscillator frequency of 11.0592MHz. Using timer 1 and configuring the UART in mode 1 write an assembly language program that transmits the ASCII character “N” at a baud rate of 19200. Solution TH1 = 256 − 2SMOD ×Oscillator Frequency 12×32×Baud Rate (Assume) SMOD = 0 By putting baud rate 19200, we get TH1=FEh Calculate TMOD and SCON TMOD = 20h SCON = 50h Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 54 / 73
  • 55. Example -2: Transmission of character N serially Assembly Language Program ORG 0 ; reset address SJMP START ; jump over reserved area ORG 40H ; program start address START: MOV SCON, #50H ; serial mode 1 MOV TMOD, #20H ; timer 1 mode 2 MOV TH1, #0FEH ; baud rate 9600 SETB TR1 ; turn timer 1 on AGAIN: MOV SBUF, #’N’ ; ASCII of N into SBUF HERE: JNB TI, HERE ; stay here till TI is set CLR TI ; clear TI SJMP AGAIN ; repeat END ; end of assembly language Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 55 / 73
  • 56. Example -3: Receive byte serially and send to port P1 Example - 3 8051 Microcontroller has an oscillator frequency of 11.0592 MHz. Write an assembly language program that receives a character into the serial buffer (SBUF) of the UART and writes the hex value of the character onto port 1. The UART should be configured as mode 1. Use 9600 baud rate. Solution TH1 = 256 − 2SMOD ×Oscillator Frequency 12×32×Baud Rate (Assume) SMOD = 0 By putting baud rate 9600, we get TH1=FDh Calculate TMOD and SCON TMOD = 20h SCON = 50h Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 56 / 73
  • 57. Example -3: Receive byte serially Assembly Language Program ORG 0 ; reset address SJMP START ; jump over reserved area ORG 40H ; program start address START: MOV SCON, #50H ; mode 1, REN enabled MOV TH1, #0FDH ; 9600 baud MOV TMOD, #20H ; timer 1 mode 2 SETB TR1 ; turn timer 1 on STAY: JNB RI, STAY ; stay here, until RI = 1 CLR RI ; clear RI MOV A, SBUF ; move character from buffer to A MOV P1, A ; hex value onto port 1 RETI ; return from interrupt END ; no more assembly language Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 57 / 73
  • 58. Example -4: Transmission of message BHEL serially Example - 4 8051 Microcontroller has an oscillator frequency of 11.0592 MHz. write an assembly language program to transfer the message “BHEL” serially at 4800 baud rate, 8 - bit data, 1 start bit and 1 stop bit. Send the message continuously. Solution TH1 = 256 − 2SMOD ×Oscillator Frequency 12×32×Baud Rate (Assume) SMOD = 0 By putting baud rate 4800, we get TH1=FAh Calculate TMOD and SCON TMOD = 20h SCON = 50h Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 58 / 73
  • 59. Example -4: Trans. of byte serially (Method - I) Assembly Language Program ORG 0 SJMP START ORG 0040H START: MOV TMOD, #20H MOV TH1, #-6 / MOV TH1, # 0FAH MOV SCON, #50H SETB TR1 AGAIN: MOV A, #’B’ ACALL SEND MOV A, #’H’ ACALL SEND MOV A, #’E’ ACALL SEND MOV A, #’L’ ACALL SEND SJMP AGAIN Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 59 / 73
  • 60. Example -4: Trans. of byte serially (Method - I)... Assembly Language Program SEND: MOV SBUF, A HERE: JNB TI, HERE CLR TI RET Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 60 / 73
  • 61. Example - 4: Trans. of byte serially (Method - II) Assembly Language Program ORG 0 SJMP START ORG 0040H START: MOV TMOD, #20H MOV TH1, #-6 / MOV TH1, #0FAH MOV SCON, #50H SETB TR1 LAST: MOV DPTR, #MSG AGAIN: CLR A MOVC A, @A+DPTR JZ LAST ; If last character get o repeat again ACALL SEND INC DPTR SJMP AGAIN Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 61 / 73
  • 62. Example - 4: Trans. of byte serially (Method - II)... Assembly Language Program SEND: MOV SBUF, A HERE: JNB TI, HERE CLR TI RET MSG: DB ’BHEL’, 0 END Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 62 / 73
  • 63. Example -5: Transmission & Reception byte serially Example - 5 Assume that the 8051 microcontroller’s serial port is connected to the COM port of the IBM PC, and on the PC we are using the Hyper Terminal program to send and receive data serially. Port P1 and P2 of the 8051 are connected to the LED’s and switches respectively. Write an assembly language program to perform the following 1. Send to the PC the message “Microcontroller is ready” 2. Receive any data sent by the PC and put it on LEDs connected to the port P1. 3. Get data on switches connected to port P2 and send it to the PC serially. The program should perform in part (1) once but part (2) and (3) continuously. Assume the baud rate 4800 with oscillator frequency 11.0592 MHz. Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 63 / 73
  • 64. Example -5: Transmission & Reception byte serially Solution TH1 = 256 − 2SMOD ×Oscillator Frequency 12×32×Baud Rate (Assume) SMOD = 0 By putting baud rate 4800, we get TH1=FAh Calculate TMOD and SCON TMOD = 20h SCON = 50h Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 64 / 73
  • 65. Example -5: Transmission & Reception byte serially Assembly Language Program ORG 0 ; reset address SJMP START ; jump over reserved area ORG 40H ; program start address START: MOV P2, #0FFH ; Port P2 configured as an input port MOV SCON, #50H ; serial mode 1 MOV TMOD, #20H ; timer 1 mode 2 MOV TH1, #0FAH ; baud rate 19200 SETB TR1 ; turn timer 1 on MOV DPTR, #MSG ; load pointer for message TR MSG: CLR A MOVC A, @A+DPTR ; get the character JZ READ SW ; check for last character, get out if las ACALL SEND ; otherwise transfer message serially INC DPTR ; next character SJMP TR MSG ; stay in loop until last character is sen Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 65 / 73
  • 66. Example -5: Transmission & Reception byte serially... Assembly Language Program READ SW: MOV A, P2 ; read switches value from port P2 ACALL SEND ; transfer it serially ACALL RECEV ; get the serial data MOV P1, A ; display it on LED’s SJMP READ SW ; repeat the process SEND: MOV SBUF, A ; load the data into SBUF HERE: JNB TI, HERE ; stay here till TI set CLR TI ; clear TI RET Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 66 / 73
  • 67. Example -5: Transmission & Reception byte serially... Assembly Language Program RECEV: JNB RI, RECEV MOV A, SBUF CLR RI RET MSG: DB ’Microcontroller is ready’, 0 END ; end of assembly language Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 67 / 73
  • 68. Example - 6: Switch base Yes - No Example - 6 Assume a switch is connected to pin P0.3, write an assembly language program to monitor its status and send two messages to the serial port continuously as follows: SW = 0 send “NO” SW = 1 send “YES” Assume that crystal frequency of the 8051 is 11.0592 MHz, use 19200 baud rate and 8 - bit UART. Use SMOD =1 Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 68 / 73
  • 69. Example - 6: Transmission & Reception byte serially Solution TH1 = 256 − 2SMOD ×Oscillator Frequency 12×32×Baud Rate (Given) SMOD = 1 By putting baud rate 19200, we get TH1=FDh Calculate TMOD and SCON TMOD = 20h SCON = 50h Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 69 / 73
  • 70. Example - 6: Switch base Yes - No Assembly Language Program ORG 0 ; reset address SJMP START ; jump over reserved area ORG 40H ; program start address START: MOV A, PCON SETB ACC.7 MOV PCON, A MOV SCON, #50H ; serial mode 1 MOV TMOD, #20H ; timer 1 mode 2 MOV TH1, #0FDH ; baud rate 19200 SETB TR1 ; turn timer 1 on SETB P0.3 ; make port pin P0.3 as an input port CHECK: JB P0.3, NEXT Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 70 / 73
  • 71. Example - 6: Switch base Yes - No... Assembly Language Program MOV DPTR, #MSG1 ; If SW = 0 then send message NO REP1: CLR A MOVC A, @A+DPTR ; read the message JZ CHECK ; check for last character ACALL SEND ; send message serially INC DPTR ; go for next byte SJMP REP1 NEXT: MOV DPTR, #MSG2 ; if SW = 1 then send message YES REP2: CLR A MOVC A, @A+DPTR ; read the message JZ CHECK ; check for last character ACALL SEND ; send message serially INC DPTR ; go for next byte SJMP REP2 Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 71 / 73
  • 72. Example - 6: Switch base Yes - No... Assembly Language Program SEND: MOV SBUF, A ; copy A into SBUF for serial transmission HERE: JNB TI, HERE ; stay here till TI set CLR TI ; clear TI RET MSG1: DB ’NO’, 0 MSG2: DB ’YES’, 0 END ; end of assembly language Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 72 / 73
  • 73. Thank you Please send your feedback at nbahadure@gmail.com For more details and updates kindly visit https://sites.google.com/site/nileshbbahadure/home Main Slide Dr. Nilesh Bhaskarrao Bahadure () Unit - III (Part I) July 25, 2021 73 / 73