SlideShare a Scribd company logo
1 of 20
UART
SERIAL V/S PARALLEL COMMUNICATION
2
SERIAL COMMUNICATION IN AVR
USRT
 AVR microcontrollers have a dedicated hardware for serial
communication; this part is called Universal Synchronous
Asynchronous Receiver and Transmitter (USRT).
 You just have to supply the data to transmit and it will do the
rest.
 The data to be transmitted is written to one of the register of
USRT and USRT transmits it.
 Also USART automatically senses the transmission of RX line and
then inputs the whole Byte and when it has the byte it informs
the CPU to read the data from one of its registers.
BAUD RATE AND BIT RATE
 Baud rate is the number of bits transmitted
in one second.
 Bit Rate is the number of data bits
transmitted in one second.
 Both of them has the same unit
‘bits/second’.
 Baud rate is determined by the number of
bits in one frame while bit rate is
determined by the number of data its in
that frame.
 Atmega16 support five different data sizes
5,6,7,8 and 9 bits.
RS232 COMMUNICATION
 RS232 is a asynchronous serial
communication protocol widely used in
computers and digital systems.
 It is called asynchronous because there is no
separate synchronizing clock signal as there
are in other serial protocols like SPI and I2C.
 The Protocol is such that it automatically
synchronize itself.
 We can use RS232 to easily create a data link
between our MCU based project and
standard PC.
 Excellent example is a commercial serial PC
mouse.
RS232
 In Rs 232 there are two data lines RX and TX.
 TX is the wire in which the data is sent out to other device.
 RX is the line in which other device put the data it need to
sent to the device.
 We know that a HIGH = +5V and LOW= 0V in TTL/MCU
circuits nut in RS232 a HIGH= -12V and a LOW =+12V.This
increases the range and reliability of data transfer.
 Thus to interface a RS232 with the MCU we need to use an
IC MAX232.As there is clock line so for synchronization
accurate timing is required so transmissions are carried
out with certain standard speeds.
 The speeds are measured in bits per second. Number of
bits transmitted is also known as baud rate. Some standard
baud rates are1200, 2400, 4800, 9600, 19200, 38400,
57600, 115200……..etc
UART OF AVR MICROCONTROLLERS
 The UART of AVR is versatile and can
be setup for various different mode as
required by your application.
 The Universal Synchronous and
Asynchronous serial Receiver and
Transmitter
 (UART) is a highly flexible serial
communication device.
 The UART of the AVR is Connected to
the CPU by the following Six Registers
UCSRA
 RXC: Reception Complete: This bit shows the completion of Reception of
a frame by the USART. If the receiver has received a complete byte it sets
this bit as 1 otherwise it remains 0.
 TXC: Transmission Complete: This bit shows the completion of
Transmission of a frame by the USART. If the transmitter has transmitted a
complete byte it sets this bit as 1 otherwise it remains 0.
 UDRE: USART Data Register Empty: This bit shows the status of UDR.
This bit set if the UDR is empty otherwise reset.
Bit No 7 6 5 4 3 2 1 0
Name RXC TXC UDRE FE DOR PE U2X MPCM
Initial Val 0 0 1 0 0 0 0 0
CONTINUE…..
 FE: Framing Error: This bit shows any error in the frame transmitted or
received using USART. This bit is high (‘1’) when there is any error in the
frame transmitted or received otherwise it is low (‘0’).
 DOR: Data Over Run: This bit shows where they data bit received have
overflowed or not. This bit is high if the data received has overflowed the bit
size of UDR otherwise it is low.
 PE: Parity Error: This bit shows any error in the parity bits, if occurred.
This bit is set if there is a parity error in the frame received otherwise it is
reset.
 U2X: Double Speed Transmission: This bit when high doubles the speed at
which the frame is being transmitted.
 MPCM: Multi Processor Communication Mode: This bit is high when the
mode of operation of the USART is Multi Processor otherwise it is low.
UCSRB
 RXCIE: Receiver Complete Interrupt Enable: When this bit is set, an
interrupt is generated at the completion of the reception of a byte.
 TXCIE: Transmitter Complete Interrupt Enable: When this bit is set,
an interrupt is generated when the transmission gets completed of a
byte.
 UDRIE: USART Data Register Interrupt Enable: When this bit is set,
an interrupt is generated whenever the UDR is Empty.
Bit No 7 6 5 4 3 2 1 0
Name RXCIE TXCIE UDRIE RXEN TXEN UCSZ2 RXB8 TXB8
Initial Val 0 0 0 0 0 0 0 0
CONTINUE…..
 RXEN: Receiving Enable: This bit is set whenever we want to receive some byte
using USART.
 TXEN: Transmission Enable: This bit is set whenever we want to transmit some
byte using USART.
 UCSZ2: USART Character Size Bit 3: This is the MSB bit of the three bits needed
to set the data size in USART communication. The other two bits are available in
UCSRC register.
 RXB8: Received Bit 8th: This Bit is used to Store the 8th bit in 9 bit frame size of
data Communication. If a 9 bit frame is received in 9 bit frame size
communication mode, the LSB is stored at this position.
 TXB8: transmitted bit 8th : This bit is used to store the 8th bit in 9 bit frame size
of data communication. If a 9 bit frame is to be transmitted, the LSB is stored at
this Position.
UCSRC
 URSEL: USART Register Select: The UCSRC and the UBRRH register
shares same address so to determine which register user want to write
is decided with the 7th (last) bit of data. If it is 1 then the data is written
to USCRC else it goes to UBRRH.
Bit No 7 6 5 4 3 2 1 0
Name URSEL UMSEL UPM1 UPM0 USBS UCSZ1 UCSZ0 UCPOL
Initial Val 0 0 0 0 0 0 0 0
CONTINUE…..
 UPM: USART Parity Mode: The parity to be used while communicating
is decided by the combination of 5th and 4th bit of this register.
UPM1 UPM0 Parity Used
0 0 Disabled
0 1 Reserved
1 0 Enabled, Even Parity
1 1 Enabled, Odd Parity
CONTINUE…..
 USBS: USART Stop Bit Select: This bit is used to select the number of
stop bits in the transfer.
USBS Stop Bit(s)
0 1 BIT
1 2 BIT
CONTINUE….
 UCSZ: USART Character Size: These bits decide the number of data
bits that will be present in each frame that will be communicated. It is a
combination of 3 bits (UCSZ2, UCSZ1 and UCSZ0). You can select among
5,6,7,8 or 9 bit frame.
UCSZ2 UCSZ1 UCSZ0 Character Size
0 0 0 5Bit
0 0 1 6Bit
0 1 0 7Bit
0 1 1 8Bit
1 0 0 Reserved
1 0 1 Reserved
1 1 0 Reserved
1 1 1 9Bit
USART BAUD RATE REGISTER
 It is a 16 bit register. The higher byte of the bud rate is stored in UBRRH while the
lower value of the baud rate is stored in UBRRL. This register is used by the
USART to generate the data transmission at specified speed.
 The UBRR value is calculated according to following formula
 Where fosc is your CPU frequency
 UBRR can hold only integer value. So it is better to use the baud rates that give
UBRR value that is purely integer or very close to integer. So if UBRR value comes
to be 7.68 and you decide to use UBRR=8 then it has high error percentage, and
communication is unreliable.
USART INITIALIZING
void usart_init()
{
UBRRL=25;
UCSRB|=(1<<TXEN)|(1<<RXEN);
UCSRC|=(1<<URSEL)|(1<<USBS)|(1<<UCSZ1)|(1<<UCSZ0);
}
TRANSMISSION USING USART
void usart_transmit(unsigned int data)
{
while(!( UCSRA & (1<<UDRE)));
UDR=data;
}
RECEPTION USING USART
unsigned int usart_receive(void)
{
while((UCSRA & (1<<RXC))==0);
return UDR;
}
THANK YOU…

More Related Content

What's hot

I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)
Varun Mahajan
 
UART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPTUART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPT
Sai_praneeth
 
I2C And SPI Part-23
I2C And  SPI Part-23I2C And  SPI Part-23
I2C And SPI Part-23
Techvilla
 

What's hot (20)

I2C BUS PROTOCOL
I2C BUS PROTOCOLI2C BUS PROTOCOL
I2C BUS PROTOCOL
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
I2C
I2CI2C
I2C
 
I2 c protocol
I2 c protocolI2 c protocol
I2 c protocol
 
AMBA 2.0 PPT
AMBA 2.0 PPTAMBA 2.0 PPT
AMBA 2.0 PPT
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)
 
I2C introduction
I2C introductionI2C introduction
I2C introduction
 
UART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPTUART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPT
 
UART
UART UART
UART
 
UVM Driver sequencer handshaking
UVM Driver sequencer handshakingUVM Driver sequencer handshaking
UVM Driver sequencer handshaking
 
axi protocol
axi protocolaxi protocol
axi protocol
 
I2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolI2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication Protocol
 
UART
UARTUART
UART
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
 
AHB To APB BRIDGE.pptx
AHB To APB BRIDGE.pptxAHB To APB BRIDGE.pptx
AHB To APB BRIDGE.pptx
 
Local Interconnect Network
Local Interconnect NetworkLocal Interconnect Network
Local Interconnect Network
 
USB protocol
USB protocolUSB protocol
USB protocol
 
AMBA Ahb 2.0
AMBA Ahb 2.0AMBA Ahb 2.0
AMBA Ahb 2.0
 
I2C And SPI Part-23
I2C And  SPI Part-23I2C And  SPI Part-23
I2C And SPI Part-23
 

Viewers also liked

News Media Network Analysis: Comparing Media Systems Mathematically
News Media Network Analysis: Comparing Media Systems MathematicallyNews Media Network Analysis: Comparing Media Systems Mathematically
News Media Network Analysis: Comparing Media Systems Mathematically
Daemin Park
 
Skin Donation
Skin DonationSkin Donation
Skin Donation
palkun
 
dịch vụ thiết kế phim quảng cáo uy tín
dịch vụ thiết kế phim quảng cáo uy tíndịch vụ thiết kế phim quảng cáo uy tín
dịch vụ thiết kế phim quảng cáo uy tín
gaston478
 
Top 8 medical billing clerk resume samples
Top 8 medical billing clerk resume samplesTop 8 medical billing clerk resume samples
Top 8 medical billing clerk resume samples
davimores
 
E-Catalog -- Yes!Star -- Greg
E-Catalog -- Yes!Star -- GregE-Catalog -- Yes!Star -- Greg
E-Catalog -- Yes!Star -- Greg
? ?
 

Viewers also liked (20)

Serial Communication Part-16
Serial Communication Part-16Serial Communication Part-16
Serial Communication Part-16
 
Uart
UartUart
Uart
 
Input Output programming in AVR microcontroller
Input  Output  programming in AVR microcontrollerInput  Output  programming in AVR microcontroller
Input Output programming in AVR microcontroller
 
USART
USARTUSART
USART
 
8051 serial communication-UART
8051 serial communication-UART8051 serial communication-UART
8051 serial communication-UART
 
Tampa Stormwater Assessment
Tampa Stormwater AssessmentTampa Stormwater Assessment
Tampa Stormwater Assessment
 
News Media Network Analysis: Comparing Media Systems Mathematically
News Media Network Analysis: Comparing Media Systems MathematicallyNews Media Network Analysis: Comparing Media Systems Mathematically
News Media Network Analysis: Comparing Media Systems Mathematically
 
Song 365 ngay_mot_nam_nxb_tong_hop_2012_nguyen_hien_le_150_trang_4119
Song 365 ngay_mot_nam_nxb_tong_hop_2012_nguyen_hien_le_150_trang_4119Song 365 ngay_mot_nam_nxb_tong_hop_2012_nguyen_hien_le_150_trang_4119
Song 365 ngay_mot_nam_nxb_tong_hop_2012_nguyen_hien_le_150_trang_4119
 
IJRES JAGADEESH
IJRES JAGADEESHIJRES JAGADEESH
IJRES JAGADEESH
 
Lesson 2
Lesson 2Lesson 2
Lesson 2
 
6 Tips for Social Media
6 Tips for Social Media6 Tips for Social Media
6 Tips for Social Media
 
Opening Session | Marc A. Scorca
Opening Session | Marc A. ScorcaOpening Session | Marc A. Scorca
Opening Session | Marc A. Scorca
 
Skin Donation
Skin DonationSkin Donation
Skin Donation
 
SmartCall - Phase 3 Pitchdeck
SmartCall - Phase 3 PitchdeckSmartCall - Phase 3 Pitchdeck
SmartCall - Phase 3 Pitchdeck
 
dịch vụ thiết kế phim quảng cáo uy tín
dịch vụ thiết kế phim quảng cáo uy tíndịch vụ thiết kế phim quảng cáo uy tín
dịch vụ thiết kế phim quảng cáo uy tín
 
Resume140515
Resume140515Resume140515
Resume140515
 
Top 8 medical billing clerk resume samples
Top 8 medical billing clerk resume samplesTop 8 medical billing clerk resume samples
Top 8 medical billing clerk resume samples
 
diseñadores venezolanos he internacionales y su aporte al diseño
diseñadores venezolanos he internacionales y su aporte al diseño diseñadores venezolanos he internacionales y su aporte al diseño
diseñadores venezolanos he internacionales y su aporte al diseño
 
IJMER-41023034
IJMER-41023034IJMER-41023034
IJMER-41023034
 
E-Catalog -- Yes!Star -- Greg
E-Catalog -- Yes!Star -- GregE-Catalog -- Yes!Star -- Greg
E-Catalog -- Yes!Star -- Greg
 

Similar to UART

Serial Communication In Atmega 16
Serial Communication In Atmega 16Serial Communication In Atmega 16
Serial Communication In Atmega 16
Suren Kumar
 
Gsm presentation
Gsm presentationGsm presentation
Gsm presentation
samuelhard
 
Gsm presentation
Gsm presentationGsm presentation
Gsm presentation
samuelhard
 
Data Encoding for Wireless Transmission
Data Encoding for Wireless TransmissionData Encoding for Wireless Transmission
Data Encoding for Wireless Transmission
Sean McQuay
 
Embedded Communications Protocols UNIT 3PDF.pdf
Embedded Communications Protocols UNIT 3PDF.pdfEmbedded Communications Protocols UNIT 3PDF.pdf
Embedded Communications Protocols UNIT 3PDF.pdf
kanyaakiran
 

Similar to UART (20)

USART.pptx
USART.pptxUSART.pptx
USART.pptx
 
Firmware implementation of UART using Bare metal programming
Firmware implementation of UART using Bare metal programmingFirmware implementation of UART using Bare metal programming
Firmware implementation of UART using Bare metal programming
 
Serial Communication In Atmega 16
Serial Communication In Atmega 16Serial Communication In Atmega 16
Serial Communication In Atmega 16
 
Gsm presentation
Gsm presentationGsm presentation
Gsm presentation
 
Gsm presentation
Gsm presentationGsm presentation
Gsm presentation
 
serial-200505101453.pdf
serial-200505101453.pdfserial-200505101453.pdf
serial-200505101453.pdf
 
Serial Communication
Serial CommunicationSerial Communication
Serial Communication
 
Lecture 10 (serial communication)
Lecture 10 (serial communication)Lecture 10 (serial communication)
Lecture 10 (serial communication)
 
Tutorial
TutorialTutorial
Tutorial
 
AN INTRODUCTION TO SERIAL PORT INTERFACING
AN INTRODUCTION TO SERIAL PORT INTERFACINGAN INTRODUCTION TO SERIAL PORT INTERFACING
AN INTRODUCTION TO SERIAL PORT INTERFACING
 
Serial Communication Uart soc
Serial Communication  Uart socSerial Communication  Uart soc
Serial Communication Uart soc
 
Universal asynchronous receiver_transmitter_uart_rs232
Universal asynchronous receiver_transmitter_uart_rs232Universal asynchronous receiver_transmitter_uart_rs232
Universal asynchronous receiver_transmitter_uart_rs232
 
6 STM32's USART.ppt
6 STM32's USART.ppt6 STM32's USART.ppt
6 STM32's USART.ppt
 
Data Encoding for Wireless Transmission
Data Encoding for Wireless TransmissionData Encoding for Wireless Transmission
Data Encoding for Wireless Transmission
 
Fpga implementation of utmi with usb 2.O
Fpga implementation of  utmi  with usb 2.O Fpga implementation of  utmi  with usb 2.O
Fpga implementation of utmi with usb 2.O
 
Embedded Communications Protocols UNIT 3PDF.pdf
Embedded Communications Protocols UNIT 3PDF.pdfEmbedded Communications Protocols UNIT 3PDF.pdf
Embedded Communications Protocols UNIT 3PDF.pdf
 
Universal Serial Communication Interface
Universal Serial Communication InterfaceUniversal Serial Communication Interface
Universal Serial Communication Interface
 
Universal Asynchronous Receive and transmit IP core
Universal Asynchronous Receive and transmit IP coreUniversal Asynchronous Receive and transmit IP core
Universal Asynchronous Receive and transmit IP core
 
UART Serial Communication Module Design and Simulation Based on VHDL
UART Serial Communication Module Design and Simulation Based on VHDLUART Serial Communication Module Design and Simulation Based on VHDL
UART Serial Communication Module Design and Simulation Based on VHDL
 
Serial Port Device Driver
Serial Port Device DriverSerial Port Device Driver
Serial Port Device Driver
 

UART

  • 2. SERIAL V/S PARALLEL COMMUNICATION 2
  • 3. SERIAL COMMUNICATION IN AVR USRT  AVR microcontrollers have a dedicated hardware for serial communication; this part is called Universal Synchronous Asynchronous Receiver and Transmitter (USRT).  You just have to supply the data to transmit and it will do the rest.  The data to be transmitted is written to one of the register of USRT and USRT transmits it.  Also USART automatically senses the transmission of RX line and then inputs the whole Byte and when it has the byte it informs the CPU to read the data from one of its registers.
  • 4. BAUD RATE AND BIT RATE  Baud rate is the number of bits transmitted in one second.  Bit Rate is the number of data bits transmitted in one second.  Both of them has the same unit ‘bits/second’.  Baud rate is determined by the number of bits in one frame while bit rate is determined by the number of data its in that frame.  Atmega16 support five different data sizes 5,6,7,8 and 9 bits.
  • 5. RS232 COMMUNICATION  RS232 is a asynchronous serial communication protocol widely used in computers and digital systems.  It is called asynchronous because there is no separate synchronizing clock signal as there are in other serial protocols like SPI and I2C.  The Protocol is such that it automatically synchronize itself.  We can use RS232 to easily create a data link between our MCU based project and standard PC.  Excellent example is a commercial serial PC mouse.
  • 6. RS232  In Rs 232 there are two data lines RX and TX.  TX is the wire in which the data is sent out to other device.  RX is the line in which other device put the data it need to sent to the device.  We know that a HIGH = +5V and LOW= 0V in TTL/MCU circuits nut in RS232 a HIGH= -12V and a LOW =+12V.This increases the range and reliability of data transfer.  Thus to interface a RS232 with the MCU we need to use an IC MAX232.As there is clock line so for synchronization accurate timing is required so transmissions are carried out with certain standard speeds.  The speeds are measured in bits per second. Number of bits transmitted is also known as baud rate. Some standard baud rates are1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200……..etc
  • 7. UART OF AVR MICROCONTROLLERS  The UART of AVR is versatile and can be setup for various different mode as required by your application.  The Universal Synchronous and Asynchronous serial Receiver and Transmitter  (UART) is a highly flexible serial communication device.  The UART of the AVR is Connected to the CPU by the following Six Registers
  • 8. UCSRA  RXC: Reception Complete: This bit shows the completion of Reception of a frame by the USART. If the receiver has received a complete byte it sets this bit as 1 otherwise it remains 0.  TXC: Transmission Complete: This bit shows the completion of Transmission of a frame by the USART. If the transmitter has transmitted a complete byte it sets this bit as 1 otherwise it remains 0.  UDRE: USART Data Register Empty: This bit shows the status of UDR. This bit set if the UDR is empty otherwise reset. Bit No 7 6 5 4 3 2 1 0 Name RXC TXC UDRE FE DOR PE U2X MPCM Initial Val 0 0 1 0 0 0 0 0
  • 9. CONTINUE…..  FE: Framing Error: This bit shows any error in the frame transmitted or received using USART. This bit is high (‘1’) when there is any error in the frame transmitted or received otherwise it is low (‘0’).  DOR: Data Over Run: This bit shows where they data bit received have overflowed or not. This bit is high if the data received has overflowed the bit size of UDR otherwise it is low.  PE: Parity Error: This bit shows any error in the parity bits, if occurred. This bit is set if there is a parity error in the frame received otherwise it is reset.  U2X: Double Speed Transmission: This bit when high doubles the speed at which the frame is being transmitted.  MPCM: Multi Processor Communication Mode: This bit is high when the mode of operation of the USART is Multi Processor otherwise it is low.
  • 10. UCSRB  RXCIE: Receiver Complete Interrupt Enable: When this bit is set, an interrupt is generated at the completion of the reception of a byte.  TXCIE: Transmitter Complete Interrupt Enable: When this bit is set, an interrupt is generated when the transmission gets completed of a byte.  UDRIE: USART Data Register Interrupt Enable: When this bit is set, an interrupt is generated whenever the UDR is Empty. Bit No 7 6 5 4 3 2 1 0 Name RXCIE TXCIE UDRIE RXEN TXEN UCSZ2 RXB8 TXB8 Initial Val 0 0 0 0 0 0 0 0
  • 11. CONTINUE…..  RXEN: Receiving Enable: This bit is set whenever we want to receive some byte using USART.  TXEN: Transmission Enable: This bit is set whenever we want to transmit some byte using USART.  UCSZ2: USART Character Size Bit 3: This is the MSB bit of the three bits needed to set the data size in USART communication. The other two bits are available in UCSRC register.  RXB8: Received Bit 8th: This Bit is used to Store the 8th bit in 9 bit frame size of data Communication. If a 9 bit frame is received in 9 bit frame size communication mode, the LSB is stored at this position.  TXB8: transmitted bit 8th : This bit is used to store the 8th bit in 9 bit frame size of data communication. If a 9 bit frame is to be transmitted, the LSB is stored at this Position.
  • 12. UCSRC  URSEL: USART Register Select: The UCSRC and the UBRRH register shares same address so to determine which register user want to write is decided with the 7th (last) bit of data. If it is 1 then the data is written to USCRC else it goes to UBRRH. Bit No 7 6 5 4 3 2 1 0 Name URSEL UMSEL UPM1 UPM0 USBS UCSZ1 UCSZ0 UCPOL Initial Val 0 0 0 0 0 0 0 0
  • 13. CONTINUE…..  UPM: USART Parity Mode: The parity to be used while communicating is decided by the combination of 5th and 4th bit of this register. UPM1 UPM0 Parity Used 0 0 Disabled 0 1 Reserved 1 0 Enabled, Even Parity 1 1 Enabled, Odd Parity
  • 14. CONTINUE…..  USBS: USART Stop Bit Select: This bit is used to select the number of stop bits in the transfer. USBS Stop Bit(s) 0 1 BIT 1 2 BIT
  • 15. CONTINUE….  UCSZ: USART Character Size: These bits decide the number of data bits that will be present in each frame that will be communicated. It is a combination of 3 bits (UCSZ2, UCSZ1 and UCSZ0). You can select among 5,6,7,8 or 9 bit frame. UCSZ2 UCSZ1 UCSZ0 Character Size 0 0 0 5Bit 0 0 1 6Bit 0 1 0 7Bit 0 1 1 8Bit 1 0 0 Reserved 1 0 1 Reserved 1 1 0 Reserved 1 1 1 9Bit
  • 16. USART BAUD RATE REGISTER  It is a 16 bit register. The higher byte of the bud rate is stored in UBRRH while the lower value of the baud rate is stored in UBRRL. This register is used by the USART to generate the data transmission at specified speed.  The UBRR value is calculated according to following formula  Where fosc is your CPU frequency  UBRR can hold only integer value. So it is better to use the baud rates that give UBRR value that is purely integer or very close to integer. So if UBRR value comes to be 7.68 and you decide to use UBRR=8 then it has high error percentage, and communication is unreliable.
  • 18. TRANSMISSION USING USART void usart_transmit(unsigned int data) { while(!( UCSRA & (1<<UDRE))); UDR=data; }
  • 19. RECEPTION USING USART unsigned int usart_receive(void) { while((UCSRA & (1<<RXC))==0); return UDR; }