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

ATMEGA8-16AI 参数 Datasheet PDF下载

ATMEGA8-16AI图片预览
型号: ATMEGA8-16AI
PDF下载: 下载PDF文件 查看货源
内容描述: 位的AVR微控制器8K字节在 - 系统内可编程Flash [-bit AVR Microcontroller with 8K Bytes In- System Programmable Flash]
分类和应用: 微控制器
文件页数/大小: 303 页 / 5122 K
品牌: ATMEL [ ATMEL ]
 浏览型号ATMEGA8-16AI的Datasheet PDF文件第138页浏览型号ATMEGA8-16AI的Datasheet PDF文件第139页浏览型号ATMEGA8-16AI的Datasheet PDF文件第140页浏览型号ATMEGA8-16AI的Datasheet PDF文件第141页浏览型号ATMEGA8-16AI的Datasheet PDF文件第143页浏览型号ATMEGA8-16AI的Datasheet PDF文件第144页浏览型号ATMEGA8-16AI的Datasheet PDF文件第145页浏览型号ATMEGA8-16AI的Datasheet PDF文件第146页  
The following code example shows a simple USART receive function that handles both  
9-bit characters and the status bits.  
Assembly Code Example(1)  
USART_Receive:  
; Wait for data to be received  
sbis UCSRA, RXC  
rjmp USART_Receive  
; Get status and ninth bit, then data from buffer  
in  
in  
in  
r18, UCSRA  
r17, UCSRB  
r16, UDR  
; If error, return -1  
andi r18,(1<<FE)|(1<<DOR)|(1<<PE)  
breq USART_ReceiveNoError  
ldi r17, HIGH(-1)  
ldi r16, LOW(-1)  
USART_ReceiveNoError:  
; Filter the ninth bit, then return  
lsr r17  
andi r17, 0x01  
ret  
C Code Example(1)  
unsigned int USART_Receive( void )  
{
unsigned char status, resh, resl;  
/* Wait for data to be received */  
while ( !(UCSRA & (1<<RXC)) )  
;
/* Get status and ninth bit, then data */  
/* from buffer */  
status = UCSRA;  
resh = UCSRB;  
resl = UDR;  
/* If error, return -1 */  
if ( status & (1<<FE)|(1<<DOR)|(1<<PE) )  
return -1;  
/* Filter the ninth bit, then return */  
resh = (resh >> 1) & 0x01;  
return ((resh << 8) | resl);  
}
Note:  
1. The example code assumes that the part specific header file is included.  
The receive function example reads all the I/O Registers into the Register File before  
any computation is done. This gives an optimal receive buffer utilization since the buffer  
location read will be free to accept new data as early as possible.  
142  
ATmega8(L)  
2486M–AVR–12/03  
 复制成功!