Datasheet

150
8246A–AVR–11/09
ATtiny2313A/4313
Note: 1. See “Code Examples” on page 6.
15.6.1 Transmitter and Receiver Flags and Interrupts
The RXC, TXC, and UDRE 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.
15.6.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.
Assembly Code Example
(1)
USART_MSPIM_Transfer:
; Wait for empty transmit buffer
sbis UCSRA, UDRE
rjmp USART_MSPIM_Transfer
; Put data (r16) into buffer, sends the data
out UDR,r16
; Wait for data to be received
USART_MSPIM_Wait_RXC:
sbis UCSRA, RXC
rjmp USART_MSPIM_Wait_RXC
; Get and return received data from buffer
in r16, UDR
ret
C Code Example
(1)
unsigned char USART_Receive( void )
{
/* Wait for empty transmit buffer */
while ( !( UCSRA & (1<<UDRE)) );
/* Put data into buffer, sends the data */
UDR = data;
/* Wait for data to be received */
while ( !(UCSRA & (1<<RXC)) );
/* Get and return received data from buffer */
return UDR;
}