AT90CAN128-16AE ATMEL Corporation, AT90CAN128-16AE Datasheet - Page 181

no-image

AT90CAN128-16AE

Manufacturer Part Number
AT90CAN128-16AE
Description
8-bit Avr Microcontroller With 128K Bytes of Isp Flash And CAN Controller.flash (Kbytes) 128 Vcc (V) 2.7-5.5 EEPROM (Kbytes) 4 SRAM (bytes) 4K CAN (mess. Obj.) 15
Manufacturer
ATMEL Corporation
Datasheet
Receiving Frames with 9 Data
Bits
4250C–CAN–03/04
The following code example shows a simple USART0 receive function based on polling
of the Receive Complete (RXC0) flag. When using frames with less than eight bits the
most significant bits of the data read from the UDR0 will be masked to zero. The
USART0 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
RXC0 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
UCSRnB 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.
Assembly Code Example
C Code Example
USART0_Receive:
unsigned char USART0_Receive (void )
{
}
; Wait for data to be received
lds
sbrs r18, RXC0
rjmp USART0_Receive
; Get and return received data from buffer
lds
ret
/* Wait for data to be received */
while ( ! (UCSR0A & (1<<RXC0)))
/* Get and return received data from buffer */
return UDR0;
1. The example code assumes that the part specific header file is included.
r18, UCSR0A
r16, UDR0
;
(1)
(1)
AT90CAN128
181

Related parts for AT90CAN128-16AE