ATmega88PA Automotive Atmel Corporation, ATmega88PA Automotive Datasheet - Page 184

no-image

ATmega88PA Automotive

Manufacturer Part Number
ATmega88PA Automotive
Description
Manufacturer
Atmel Corporation
20.6.2
184
Atmel ATmega48PA/88PA/168PA [Preliminary]
Sending Frames with 9 Data Bit
If 9-bit characters are used (UCSZn = 7), the ninth bit must be written to the TXB8 bit in
UCSRnB before the low byte of the character is written to UDRn. The following code examples
show a transmit function that handles 9-bit characters. For the assembly code, the data to be
sent is assumed to be stored in registers R17:R16.
The ninth bit can be used for indicating an address frame when using multi processor commu-
nication mode or for other protocol handling as for example synchronization.
Assembly Code Example
C Code Example
Notes:
USART_Transmit:
void USART_Transmit( unsigned int data )
{
}
; Wait for empty transmit buffer
in r16, UCSRnA
sbrs r16, UDREn
rjmp USART_Transmit
; Copy 9th bit from r17 to TXB8
cbi
sbrc r17,0
sbi
; Put LSB data (r16) into buffer, sends the data
out
ret
/* Wait for empty transmit buffer */
while ( !( UCSRnA & (1<<UDREn))) )
/* Copy 9th bit to TXB8 */
UCSRnB &= ~(1<<TXB8);
if ( data & 0x0100 )
/* Put data into buffer, sends the data */
UDRn = data;
UCSRnB |= (1<<TXB8);
1. These transmit functions are written to be general functions. They can be optimized if the
2.
contents of the UCSRnB is static. For example, only the TXB8 bit of the UCSRnB Regis-
ter is used after initialization.
See ”About Code Examples” on page 7.
UCSRnB,TXB8
UCSRnB,TXB8
UDRn,r16
;
(1)(2)
(1)(2)
9223B–AVR–09/11

Related parts for ATmega88PA Automotive