Datasheet
201
2545F–AVR–06/05
ATmega48/88/168
Note: 1. See ”About Code Examples” on page 6.
19.5.1 Transmitter and Receiver Flags and Interrupts
The RXCn, TXCn, and UDREn flags and corresponding interrupts in USART in MSPIM mode
are identical in function to the normal USART operation. However, the receiver error status flags
(FE, DOR, and PE) are not in use and is always read as zero.
19.5.2 Disabling the Transmitter or Receiver
The disabling of the transmitter or receiver in USART in MSPIM mode is identical in function to
the normal USART operation.
19.6 USART MSPIM Register Description
The following section describes the registers used for SPI operation using the USART.
19.6.1 USART MSPIM I/O Data Register - UDRn
The function and bit description of the USART data register (UDRn) in MSPI mode is identical to
normal USART operation. See “USART I/O Data Register n– UDRn” on page 187.
19.6.2 USART MSPIM Control and Status Register n A - UCSRnA
Assembly Code Example
(1)
USART_MSPIM_Transfer:
; Wait for empty transmit buffer
sbis UCSRnA, UDREn
rjmp USART_MSPIM_Transfer
; Put data (r16) into buffer, sends the data
out UDRn,r16
; Wait for data to be received
USART_MSPIM_Wait_RXCn:
sbis UCSRnA, RXCn
rjmp USART_MSPIM_Wait_RXCn
; Get and return received data from buffer
in r16, UDRn
ret
C Code Example
(1)
unsigned char USART_Receive( void )
{
/* Wait for empty transmit buffer */
while ( !( UCSRnA & (1<<UDREn)) );
/* Put data into buffer, sends the data */
UDRn = data;
/* Wait for data to be received */
while ( !(UCSRnA & (1<<RXCn)) );
/* Get and return received data from buffer */
return UDRn;
}
Bit 7 6 5 4 3 2 1 0