Javatpoint Logo
Javatpoint Logo

AVR UART/Serial Communication

In AVR microcontroller, the following sets of registers are used for communicate over UART:

  • UCSRA: In this registers flags used for various errors that might occurs during the data transmission. e.g. frame error, parity error etc.
  • UCSRC: In this registers we can set the stop bits, parity mode and so on.
  • UCSRB: In this register we are providing with lot of enable bits. For example different interrupt enable bits for transmitting and receiving the enable bits.
  • UBRRH & UBRRL: In UBRRL register, lower byte is used for storing the required Baud rate and in UBRRH register, the higher byte is used for storing the required Baud rate.

More information about the above registers can be found in a datasheet of the AVR microcontroller you are using.

The initialization of serial communication registers in assembly language is given below:

The initialization of serial communication registers in embedded C language is given below:

For transmitting data serially we required to put the data to send in 8-bit UART Data Register (UDR) and poll the empty transmit buffer at set condition. While receiving data from the receive flag, when it's set the data received from the UDR register. An example for implementing this in assembly language is given below:

For transmitting data serially we required to put the data to send in 8-bit UART Data Register (UDR) and poll the empty transmit buffer at set condition. While receiving data from the receive flag, when it's set the data received from the UDR register. An example for implementing this in embedded C language is given below:






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA