UART Communication Between Two ATmega8 Microcontrollers
In this tutorial we are going to establish a serial communication between two ATMEGA8 microcontrollers. The communication established here is UART (Universal Asynchronous Receiver Transmitter) type. By this serial communication data can be shared between two microcontrollers, which is required in various embedded systems.
Hardware: ATMEGA8 (2 pieces), power supply (5v), AVR-ISP PROGRAMMER, 100uF capacitor (connected across power supply), 1KΩ resistor (two pieces), LED , Button.
Software: Atmel studio 6.1, progisp or flash magic.
Let us understand the serial communication in AVR microcontrollers. Here ATMEGA sends data to the other ATMEGA in serial. It has other mode of communication but for easy communication we are choosing RS232. The RS232 pin of first ATMEGA8 is connected to RXD pin of second ATMEGA8.
The data communication established is programmed to have:
- Eight data bits
- Two stop bits
- No parity check bit
- Baud rate of 2400 BPS(Bits Per Second)
- Asynchronous communication (No clock share between two ATMEGA8)
So we have two set registers for two ATMEGA8 differently, where one acts as TRANSMITTER and other acts as RECEIVER.
Now for the RS232 interfacing between two ATmega microcontrollers, the following features must be satisfied for the TRANSMITTER and RECEIVER:
1. The TXD pin (data receiving feature) of first controller must be enabled for TRANSMITTER and RXD pin of second controller must be enabled for RECEIVER .
2. Since the communication is serial we need to know whenever the data byte is received, so that we can stop the program until complete byte is received. This is done by enabling a data receive complete interrupt.
3. DATA is transmitted and received to controller in 8bit mode. So two characters will be sent to the controller at a time.
4. There are no parity bits, one stop bit in the data sent by the module.
The above features are set in the controller registers; we are going to discuss them briefly,
For more detail: UART Communication Between Two ATmega8 Microcontrollers
About The Author
Leave a Comment
You must be logged in to post a comment.