Serial Communication Using ATmega8 (UART Protocol)

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: 

  1. Full Duplex Operation (Independent Serial Receive and Transmit Registers)
  2. Data format and Transmission speed are configurable.
  3. Asynchronous or Synchronous Operation
  4. Master or Slave Clocked Synchronous Operation
  5. High Resolution Baud Rate Generator
  6. Supports Serial Frames with 5, 6, 7, 8, or 9 Data bits and 1 or 2 Stop Bits
  7. Odd or Even Parity Generation and Parity Check Supported by Hardware
  8. Data OverRun Detection
  9. Framing Error Detection
  10. Three Separate Interrupts on TX Complete, TX Data Register Empty and RX Complete
  11. Multi-processor Communication Mode
  12. Double Speed Asynchronous Communication Mode

PROJECT 1: SEND DATA TO LAPTOP

On previous tutorial (Digital_OutputDigital 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");
}
  1. save the code in a particular folder and copy the uart.h and make file in that folder.
  2. you can find this folder in “necessary files” attached above named as project 1
  3. open code using Programmers Notepad then goto tools-> [WinAVR] Make All;
  4. if there is no error then connect ATmega8 to laptop then goto tools -> [WinAVR] Program
  5. After upload done Open “Tera Term” form start menu then see the result.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

Robogenesis

Start your journey with us.

I hope this message finds you well. I’m writing to inquire about your offerings in IoT, robotics, and software solutions courses. Could you please provide details regarding the curriculum, duration, and enrollment process? Thank you in advance for your assistance.

Inquiry Now