Exchange of information from one system to another system through a medium is called communication. One Person communicate with another person it may be face to face, it could be landline (through wire communication), or through mobile phone (wireless) or whatsapp, messenger, twitter (cloud based communication).
Like human being microcontroller also communicate with each other; Microcontroller to Microcontroller (M2M), Microcontroller to Person (M2P), Microcontroller to Cloud (M2C) etc.
**Communication Protocol: A set of rules and regulations that allow two electronic devices to connect and exchange the data from one and another.
The Universal Synchronous and Asynchronous serial Receiver and Transmitter (USART) is a highly-flexible serial communication device.
FEATURES:
- Full Duplex Operation (Independent Serial Receive and Transmit Registers)
- Data format and Transmission speed are configurable.
- Asynchronous or Synchronous Operation
- Master or Slave Clocked Synchronous Operation
- High Resolution Baud Rate Generator
- Supports Serial Frames with 5, 6, 7, 8, or 9 Data bits and 1 or 2 Stop Bits
- Odd or Even Parity Generation and Parity Check Supported by Hardware
- Data OverRun Detection
- Framing Error Detection
- Three Separate Interrupts on TX Complete, TX Data Register Empty and RX Complete
- Multi-processor Communication Mode
- Double Speed Asynchronous Communication Mode
PROJECT 1: SEND DATA TO LAPTOP
On previous tutorial (Digital_Output, Digital Input) we simple compile the code and send to ATmega8. Now we see how to transfer data from ATmega8 to laptop; on the other-hand we can say here we do M2M communication (i.e. Machine to Machine communication) 1st machine is ATmega8 n 2nd one is laptop. lets start sending data from ATmega8 to Laptop using UART protocol via cp2102 (USB-TTL bridge)
CIRCUIT DIAGRAM




RXD: Receive Data pin (ATMEGA8 pin2/ PD0)
TXD: Transmit Data pin (ATMEGA8 pin3/ PD1)
XCK: USART Clock pin (ATMEGA8 pin6/ PD4)
In the above circuit diagram ATmega8 connected to laptop through CP2102. CP2102 is a USB-TTL bridge which is helps to create a bridge connection bet PC to uC
INSTALL CP2102 DRIVER
Install the CP2102 driver in PC for establish for serial communication with ATmega8
follow the installation procedure below:
Download CP2102 driver
Necessary files
Or download all the necessary file
Step 1: open CP210XX_xxxx…exe file then scheck mark “I accept the agreement” -> press “Next”

Step 2: select your default place to install the file -> press “Next”

Step 3: Then Press next as shown below

Step 4: Choose your suitable Language -> Press “Next”

Step 5: Then Press Next as below.

Step 6: Then press Next .

Step 7: Finally push “Install” button to install the .exe file after the inatallation then press finsh as below screen shot for reference.


CODE:
#include //avr I/P O/p header file
#include"uart.h" //uart header file
void main()
{
uart_init(); //uart initialization
while(1) //infinity loop
printstring("Welcom to USART Protocol \n\r");
}
- save the code in a particular folder and copy the uart.h and make file in that folder.
- you can find this folder in “necessary files” attached above named as project 1
- open code using Programmers Notepad then goto tools-> [WinAVR] Make All;
- if there is no error then connect ATmega8 to laptop then goto tools -> [WinAVR] Program
- After upload done Open “Tera Term” form start menu then see the result.