INTERRUPT (SIG_USART_DATA) { if(int_data_num<(TxCounter-1)) { UDR0=*pTxBuffer++; int_data_num++; } else { int_data_num=0; TXData_Num--; } }
bool Test_Int_Send(void) { consideration if(0>=TXData_Num) { Read_Idx=Write_Idx; return false; } pTxBuffer = (unsigned char *)&Int_TXData[Read_Idx++]; if(TXDATA_ARRAY==Read_Idx) Read_Idx = 0; TxCounter = sizeof(USART_TXDataTypedef); cli(); UBRR0H=0x00; UBRR0L=0x34; UCSR0A=0x02; UCSR0B =0b00111000; //enable txd and rxd UCSR0C =0b00100110; while(!( UCSR0A & (1<<UDRE0))); UDR0 = *pTxBuffer++; sei(); return true; }
int main() { Test_Int_SendPrepare(1,2,3,5); Test_Int_Send(); while(1); }
程序如上,sei后即触发中断,但是运行到中断处理程序入口即停止。怀疑是嵌套终端,一直触发中断。如果是这样的此中断如何使用?我已经在开中断之前发送一个数据到UDR0。 |