我正在使用 CodeVisonAvr 从 USART 读取数据。但是当数据超过64字节时,我只能从USART端口读取64字节的数据。我怎样才能读取所有数据? 谢谢
#include <mega16a.h>
#include <sleep.h>
#include <delay.h>
#include <stdio.h>
char rx_buffer[256];
int rx_wr_index=0;
// USART Receiver interrupt service routine
interrupt [USART_RXC] void usart_rx_isr(void)
{
char data;
data=UDR;
rx_buffer[rx_wr_index++]=data;
if (rx_wr_index==256)rx_wr_index=0;
}
void main(void)
{
UCSRA=(0<<RXC) | (0<<TXC) | (0<<UDRE) | (0<<FE) | (0<<DOR) | (0<<UPE) | (0<<U2X) | (0<<MPCM);
UCSRB=(1<<RXCIE) | (0<<TXCIE) | (0<<UDRIE) | (1<<RXEN) | (1<<TXEN) | (0<<UCSZ2) | (0<<RXB8) | (0<<TXB8);
UCSRC=(1<<URSEL) | (0<<UMSEL) | (0<<UPM1) | (0<<UPM0) | (0<<USBS) | (1<<UCSZ1) | (1<<UCSZ0) | (0<<UCPOL);
UBRRH=0x00;
UBRRL=0x47;
// Globally enable interrupts
#asm("sei")
sleep_enable();
while (1)
{
idle() ;
puts(rx_buffer);
puts("\r\n");
delay_ms(200);
rx_wr_index=0;
}
}