ATMEGA16U2-16AU Atmel, ATMEGA16U2-16AU Datasheet - Page 158

no-image

ATMEGA16U2-16AU

Manufacturer Part Number
ATMEGA16U2-16AU
Description
8-bit Microcontrollers - MCU 16K Flash
Manufacturer
Atmel
Datasheet

Specifications of ATMEGA16U2-16AU

Product Category
8-bit Microcontrollers - MCU
Rohs
yes
Core
AVR
Data Bus Width
8 bit
Program Memory Size
16 KB
Data Ram Size
1.25 KB
Data Rom Size
512 B
Program Memory Type
Flash
Factory Pack Quantity
1250
18.7.2
7799D–AVR–11/10
Receiving Frames with 9 Data Bits
bits of the data read from the UDRn will be masked to zero. The USART has to be initialized
before the function can be used.
Note:
The function simply waits for data to be present in the receive buffer by checking the RXCn Flag,
before reading the buffer and returning the value.
If 9-bit characters are used (UCSZn=7) the ninth bit must be read from the RXB8n bit in UCS-
RnB before reading the low bits from the UDRn. This rule applies to the FEn, DORn and UPEn
Status Flags as well. Read status from UCSRnA, then data from UDRn. Reading the UDRn I/O
location will change the state of the receive buffer FIFO and consequently the TXB8n, FEn,
DORn and UPEn bits, which all are stored in the FIFO, will change.
The following code example shows a simple USART receive function that handles both nine bit
characters and the status bits.
Assembly Code Example
C Code Example
USART_Receive:
unsigned char USART_Receive( void )
{
}
; Wait for data to be received
sbis UCSRnA, RXCn
rjmp USART_Receive
; Get and return received data from buffer
in
ret
/* Wait for data to be received */
while ( !(UCSRnA & (1<<RXCn)) )
/* Get and return received data from buffer */
return UDRn;
1. See “Code Examples” on page 6.
r16, UDRn
;
(1)
(1)
ATmega8U2/16U2/32U2
158

Related parts for ATMEGA16U2-16AU