程序: void USART_Init( unsigned int baud ) { DDRD |=(1<<(2)); PORTD =0xFF; UCSRC = (1<<URSEL) | 0x06; UBRRH = (unsigned char)(baud>>8); UBRRL = (unsigned char)baud; UCSRA = 0x00; UCSRB = (1<<RXCIE)|(1<<RXEN)|(1<<TXEN); }
SIGNAL(SIG_USART_RECV) //串口接收中断服务程序 { uchar kk; //while (!(UCSRA & (1<<RXC))) //return UDR; if(UCSRA&(1<<RXC)) { kk=UDR; UCSRA&=~(1<<(RXC)); // return kk; } } 我用串口助手发送一个数据,用查询方式已经调通,但用中断方式调了许久都没有调通,程序进不了中断,请教各位朋友哪里出了问题??谢谢!(小弟第一次调AVR的中断程序)
|