欢迎访问ic37.com |
会员登录 免费注册
发布采购

ATMEGA32L-8AUR 参数 Datasheet PDF下载

ATMEGA32L-8AUR图片预览
型号: ATMEGA32L-8AUR
PDF下载: 下载PDF文件 查看货源
内容描述: [RISC Microcontroller, 8-Bit, FLASH, AVR RISC CPU, 8MHz, CMOS, PQFP44, 10 X 10 MM, 1 MM HEIGHT, 0.80 MM PITCH, GREEN, PLASTIC, MS-026ACB, TQFP-44]
分类和应用: 闪存微控制器
文件页数/大小: 347 页 / 3171 K
品牌: ATMEL [ ATMEL ]
 浏览型号ATMEGA32L-8AUR的Datasheet PDF文件第142页浏览型号ATMEGA32L-8AUR的Datasheet PDF文件第143页浏览型号ATMEGA32L-8AUR的Datasheet PDF文件第144页浏览型号ATMEGA32L-8AUR的Datasheet PDF文件第145页浏览型号ATMEGA32L-8AUR的Datasheet PDF文件第147页浏览型号ATMEGA32L-8AUR的Datasheet PDF文件第148页浏览型号ATMEGA32L-8AUR的Datasheet PDF文件第149页浏览型号ATMEGA32L-8AUR的Datasheet PDF文件第150页  
USART Initialization  
The USART has to be initialized before any communication can take place. The initial-  
ization process normally consists of setting the baud rate, setting frame format and  
enabling the Transmitter or the Receiver depending on the usage. For interrupt driven  
USART operation, the Global Interrupt Flag should be cleared (and interrupts globally  
disabled) when doing the initialization.  
Before doing a re-initialization with changed baud rate or frame format, be sure that  
there are no ongoing transmissions during the period the registers are changed. The  
TXC Flag can be used to check that the Transmitter has completed all transfers, and the  
RXC Flag can be used to check that there are no unread data in the receive buffer. Note  
that the TXC Flag must be cleared before each transmission (before UDR is written) if it  
is used for this purpose.  
The following simple USART initialization code examples show one assembly and one  
C function that are equal in functionality. The examples assume asynchronous opera-  
tion using polling (no interrupts enabled) and a fixed frame format. The baud rate is  
given as a function parameter. For the assembly code, the baud rate parameter is  
assumed to be stored in the r17:r16 registers. When the function writes to the UCSRC  
Register, the URSEL bit (MSB) must be set due to the sharing of I/O location by UBRRH  
and UCSRC.  
Assembly Code Example(1)  
USART_Init:  
; Set baud rate  
out  
out  
UBRRH, r17  
UBRRL, r16  
; Enable receiver and transmitter  
ldi  
out  
r16, (1<<RXEN)|(1<<TXEN)  
UCSRB,r16  
; Set frame format: 8data, 2stop bit  
ldi  
out  
ret  
r16, (1<<URSEL)|(1<<USBS)|(3<<UCSZ0)  
UCSRC,r16  
C Code Example(1)  
void USART_Init( unsigned int baud )  
{
/* Set baud rate */  
UBRRH = (unsigned char)(baud>>8);  
UBRRL = (unsigned char)baud;  
/* Enable receiver and transmitter */  
UCSRB = (1<<RXEN)|(1<<TXEN);  
/* Set frame format: 8data, 2stop bit */  
UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0);  
}
Note:  
1. See “About Code Examples” on page 7.  
More advanced initialization routines can be made that include frame format as parame-  
ters, disable interrupts and so on. However, many applications use a fixed setting of the  
Baud and Control Registers, and for these types of applications the initialization code  
can be placed directly in the main routine, or be combined with initialization code for  
other I/O modules.  
146  
ATmega32(L)  
2503J–AVR–10/06  
 复制成功!