| Electronic Components Datasheet Search |
|
ATmega64A Datasheet(PDF) 182 Page - ATMEL Corporation |
|
|
|||||||||||||||||||||||||||||
ATmega64A Datasheet(HTML) 182 Page - ATMEL Corporation |
|
182 / 392 page ![]() 182 8160C–AVR–07/09 ATmega64A The function simply waits for the transmit buffer to be empty by checking the UDREn flag, before loading it with new data to be transmitted. If the Data Register Empty Interrupt is utilized, the interrupt routine writes the data into the buffer. 20.6.2 Sending Frames with 9 Data Bits If 9-bit characters are used (UCSZn = 7), the ninth bit must be written to the TXB8n 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. Note: 1. These transmit functions are written to be general functions. They can be optimized if the con- tents of the UCSRnB is static. For example, only the TXB8n bit of the UCSRnB Register is used after initialization. For I/O Registers located in extended I/O map, “IN”, “OUT”, “SBIS”, “SBIC”, “CBI”, and “SBI” instructions must be replaced with instructions that allow access to extended I/O. Typically “LDS” and “STS” combined with “SBRS”, “SBRC”, “SBR”, and “CBR”. The ninth bit can be used for indicating an address frame when using Multi-processor Communi- cation mode or for other protocol handling as for example synchronization. 20.6.3 Transmitter Flags and Interrupts The USART Transmitter has two flags that indicate its state: USART Data Register Empty (UDREn) and Transmit Complete (TXCn). Both flags can be used for generating interrupts. Assembly Code Example (1) USART_Transmit: ; Wait for empty transmit buffer sbis UCSRnA,UDREn rjmp USART_Transmit ; Copy ninth bit from r17 to TXB8 cbi UCSRnB,TXB8n sbrc r17,0 sbi UCSRnB,TXB8n ; Put LSB data (r16) into buffer, sends the data out UDRn,r16 ret C Code Example (1) void USART_Transmit( unsigned int data ) { /* Wait for empty transmit buffer */ while ( !( UCSRnA & (1<<UDREn)) ) ; /* Copy ninth bit to TXB8 */ UCSRnB &= ~(1<<TXB8n); if ( data & 0x0100 ) UCSRnB |= (1<<TXB8n); /* Put data into buffer, sends the data */ UDRn = data; } |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |