Serial Communication
Introduction to Communication:-
Communication refers to the process of exchanging ideas, thoughts, and experiences between two or more persons. In IOT it refers to the process of exchange of data between two devices.
1. Parallel Communication:-
Parallel Communication is Communication in which Data is transmitted simultaneously across multiple data lines.
2. Serial Communication:-
Serial Communication is a Communication in which Data is transmitted one bit at a time across a single line.
What is the Baud Rate?
Baud rate is the rate of data at which it is transmitted over a communication channel. It is measured in bits per second.
The 8051 microcontroller uses the UART protocol for communication.
What is UART?
UART stands for: Universal Asynchronous Receiver/Transmitter
It is a hardware communication protocol used for serial communication between devices.
UART converts parallel data from a microcontroller into serial form for transmission and vice versa for reception.
Key Feature of UART
Asynchronous: No clock line is shared between sender and receiver.
Full Duplex: Can send and receive data simultaneously.Uses 2 main lines:
TX (Transmit) – Sends data out.
RX (Receive) – Receives data in
Serial Communication-Related Registers and Their Functions:
1. SCON:- SCON (Serial Control Register) is an 8-bit Special Function Register (SFR) in the 8051 microcontroller used to configure and control serial communication (UART).
SM0 |
SM1 |
SM2 |
REN |
TB8 |
RB8 |
TI |
RI |
SM0 & SM1:- These two bits are used together to select one of the four serial communication modes in 8051. They control how many bits are transmitted/received and how the baud rate is generated.
Serial Communication Mode Selection Table :
Mode | Name | Duplex | Baud Rate | Data Frame | Notes |
---|---|---|---|---|---|
0 | Shift Register | Half-duplex | Fixed | 8-bit | Clock on TxD; not standard UART |
1 | 8-bit UART | Full-duplex | Variable | Start + 8-bit + Stop | Most common mode; standard UART |
2 | 9-bit UART | Full-duplex | Fixed | Start + 8-bit + 9th bit + Stop | 9th bit used for multiprocessor communication |
3 | 9-bit UART | Full-duplex | Variable | Start + 8-bit + 9th bit + Stop | Same as Mode 2, but with variable baud rate |
SM2:- It is used for microcontroller-to-microcontroller (MC to MC) communication — especially in multiprocessor setups.
REN(Receiver Enable):- Controls whether the 8051 can receive data or not.
REN=1: Receiving enabled
REN = 0
: Receiving disabled.- When data is written to SBUF, it is placed into the transmit buffer and automatically sent out through the TXD (P3.1) pin.
- When data is received via RXD (P3.0), it is automatically stored in the receive buffer part of SBUF, and the RI flag is set.
- One for transmitting (write-only)
- One for receiving (read-only)
|
|
|
|
|
|
|
|
Task 1:- Print a single character on Serial monitor.
Code:-
Code:-
Code:-
0 Comments