请大家帮忙看下这段mega128串口程序有什么问题,ICCAVR下的,没法接收数据啊
[code]#include
#include
//==================================
void port_init(void)
{
PORTA = 0xFF;
DDRA = 0x00;
PORTB = 0xFF;
DDRB = 0xFF;
PORTC = 0xFF;
DDRC = 0x00;
PORTD = 0xFF;
DDRD = 0x00;
PORTE = 0xFF;
DDRE = 0x02;
}
//**********************************************
void uart0_init(void)
{
UCSR0B = 0x00;
UCSR0A = 0x02;
UCSR0C = 0x06;
UBRR0L = 0x67; //波特率为9600
UBRR0H = 0x00;
UCSR0B = 0x18;
}
//**********************************************
void init_devices(void)
{
port_init();
uart0_init();
}
//**********************************************
void uart0_send(unsigned char i)
{
while(!(UCSR0A&(1<
UDR0=i;
}
//************************************************
unsigned char uart0_receive(void)
{
while(!(UCSR0A&(1<
return UDR0;
}
//---------------------------------------------------------------
void main(void)
{
unsigned char temp;
init_devices();
while(1)
{
temp=uart0_receive();
uart0_send(temp);
}
}