AVR Microcontroller (Atmel 8) Serial Communication USART ConfigurationMicrocontroller is a control device that contains a number of peripherals like RAM, ROM TIMERS, serial data communication, etc., which are required to perform some pre-defined tasks. Nowadays, advanced type of microcontrollers are used in a wide variety of applications as per their capability and feasibility to perform some desired tasks and these controllers include 8051, AVR and PIC microcontroller. In this article, we are going to learn about advanced AVR family microcontroller and its programming.AVR MicrocontrollerThe AVR is a type of controlling device manufactured by the Atmel Corporation in 1996. The AVR does not stand for anything, it is just a name. The AVR microcontrollers consist of the Harvard architecture, and therefore, the device run very fast with a reduced number of machine level instructions (RISC). The AVR microcontrollers consist of special features compared with other microcontroller such as 6-sleep modes, inbuilt ADC, internal oscillator and serial data communication, etc. The AVR microcontrollers are available in different configurations of 8-bit, 16-bit, and 32-bit to perform various operations. AVR MicrocontrollerUSART Serial Data Communication in AVR MicrocontrollerThe USART stands for universal synchronous and asynchronous receiver and transmitter. It is a serial communication of two protocols. This protocol is used for transmitting and receiving the data bit by bit with respect to clock pulses on a single wire. The AVR microcontroller has two pins: TXD and RXD, which are specially used for transmitting and receiving the data serially. Any AVR microcontroller consists of USART protocol with its own features.USART Communication in AVR MicrocontrollerThe Main Features of AVR USARTThe USART protocol supports the full-duplex protocol.It generates high resolution baud rate.It supports transmitting serial data bits from 5 to 9 and it consists of two stop bits.USART Pin ConfigurationThe USART of AVR consists of three Pins:RXD: USART receiver pin (ATMega8 PIN 2; ATMega16/32 Pin 14)TXD: USART transmitter pin (ATMega8 PIN 3; ATMega16/32 Pin 15)XCK: USART clock pin (ATMega8 PIN 6; ATMega16/32 Pin 1)Modes of OperationThe AVR microcontroller of USART protocol operates in three modes which are: Asynchronous Normal ModeAsynchronous Double Speed ModeSynchronous ModeModes of OperationAsynchronous Normal ModeIn this mode of communication, the data is transmitted and received bit by bit without clock pulses by the predefined baud rate set by the UBBR register.Asynchronous Double Speed ModeIn this mode of communication, the data transferred at double the baud rate is set by the UBBR register and set U2X bits in the UCSRA register. This is a high-speed mode for synchronous communication for transmitting and receiving the data quickly. This system is used where accurate baud rate settings and system clock are required.Synchronous ModeIn this system, transmitting and receiving the data with respect to clock pulse is set UMSEL=1 in the UCSRC register.USART Configuration In AVR microcontrollerUSART can be configured using five registers such as three control registers, one data register and baud-rate-selection register, such as UDR, UCSRA, UCSRB, UCSRC and UBRR.7 Steps for Composing the ProgramStep1: Calculate and Set the Baud RateThe baud rate of USART/UART is set by the UBRR registrar. This register is used to generate the data transmission at the specific speed. The UBRR is a 16-bit register. Since the AVR is a 8-bit microcontroller and its any register size is 8-bit. Hence, here the 16-bit UBRR register is composed of two 8-bit registers such as UBRR (H), UBRR(L).The formula of the baud rate isBAUD= Fosc/(16*(UBBR+1))The formula of the UBRR register isUBRR= Fosc/( 16*(BAUD-1))The frequency of the AVR microcontroller is 16MHz=16000000; Let us assume the baud rate as 19200Bps, thenUBRR= 16000000/(16*(19200-1))UBRR= 16000000/(16*(19200-1))UBRR= 51.099Eventually find the baud rateBAUD= 16000000/( 16*(51+1)) UBRR= 19230bpsStep2: Data Mode SelectionThe data transmission mode, start bit and stop bit and the character size is set by the control and status register UCSRC.Data Mode SelectionStep3: Data Transmission Mode SelectionThe synchronous and asynchronous mode is selected by the UMSEL bit of the control status register. If we give UMSEL=0, then the USART operates in asynchronous mode, otherwise operates in synchronous mode.Data Transmission Mode SelectionStep4: Start Bit and Stop BitThe start bit and stop bits are a way for sending and receiving the data serially. Generally any data fame consists of one stat bit and one stop bit, but the AVR microcontroller has one start bit and two stop bits for processing the data. The extra stop bit can be useful for adding a little extra receive processing time. It is especially useful for high data transfer rates, whereas the data transfer speed is very high, so we don’t get proper data. Thus, we can increase the processing time by using two stop bits to get the proper data.Start Bit and Stop BitThe number of stop bits is selected by the USBS bit of UCSRC – the control status register. The USBS=0, for one stop bit, and USBS=1, for two stop bits.Step5: Set the Character SizeAs in case with the basic microcontrollers sending and receiving the byte of data(8-bits) at a time, whether in a AVR microcontroller, we can choose a data frame format in each frame by the UCSZ bit of the UCSRC register.Data Frame FormatStep6: Store the Received DataThe AVR microcontroller consists of a UDR buffer register for transmitting and receiving data. The UDR is a 16-bit buffer register wherein 8-bits are used for receiving (RXB) the data and other bits are used for transmitting the data (TXB). Transmitting data buffer register will be the destination to UDR register for the written data on its location. Receiving data buffer register will be returning the content of the UDR register.Step7: Transmitter and Receiver EnablingThe transmitted and received data will be allowed by the RXC and TXC pins of the microcontroller which are set by the UCSRA register of the microcontroller. This flag bit set by the microcontroller for the data is completed by receiving and transmitting (TXC=RXC=1).Double the Baud RateWe can double the transfer rate of the USART communication of the AVR microcontroller from 16 bits to 8-bits effectively by the U2X –bit in the UCSRA register. This bit effects only on asynchronous operation. If we can set this bit (U2X=1), it will reduce the baud rate from 16-bit to 8-bit effectively doubling the transfer rate for synchronous communication.This is an advanced feature of the AVR microcontroller for speedy processing of the data.USART ProgramEvery microcontroller is predefined with a specific IDE, and based on this IDE, microcontrollers are programmed with embedded C or assembly language. The AVR microcontroller programming is developed by the AVR studio. Furthermore, If you want additional information about the steps to build microcontroller based projects, or detailed information on this topic, you can contact us by commenting below. Share This Post: Facebook Twitter Google+ LinkedIn Pinterest Post navigation ‹ Previous Electronic Starters for Single Phase Induction Motor With ProtectionNext › Know about Under and Overvoltage Protection Circuit with Working Related Content AVR Atmega8 Microcontroller Architecture & Its Applications Stepper Motor Control Using AVR (Atmega) Microcontroller AVR Microcontroller Projects for Engineering Students Types of AVR Microcontroller – Atmega32 & ATmega8Add Comment Cancel replyComment:Name * Email * Website