刚上手ADUC7060,调试UART的时候,收发采样查询的方式,都可以操作,
但是想用中断接收,确始终进不了中断~~
int main(void)
{
POWKEY1 = 0x1; //before to write data to POWCON0,must first write 0x01 to the POWKEY1
POWCON0 = 0x68; // Set core to max CPU speed of 10.24Mhz
POWKEY2 = 0xF4;
//reset wifi module
ResetWifi();
//init uart 115200bps N 8
GP1CON =0x11;//P1.0,P1.1?
COMCON0 = BIT7; // Enable access to COMDIV registers
COMDIV0 = 0x02; // Set baud rate to 115200.
COMDIV1 = 0x00;
COMDIV2 = 0x8b1c; // Enable fractional divider for more accurate baud rate setting
COMCON0 = BIT0 + BIT1;
/************************************************************************************************/
//串口中断接收
COMIEN0 = BIT0 + BIT1; // Enable UART interrupts when Rx full and Tx buffer empty.
// IRQP1 = 0;//priority set
IRQEN = BIT11; // Enable UART interrupt source
// IRQCONN = 0x01;//interrupt nesting
bSendResultToUART = 0;
/************************************************************************************************/
Ct_temp = 0;
while(1)
{
/************************************************************************************************/
/*查询模式,可以使用*/
// if ((COMSTA0 & 0x01) == 0x01) // If the Rx buffer full bit is set
// {
// RecDataTemp = COMRX; // read COMRX register
// COMTX = RecDataTemp+1; // Load Tx buffer
// while ((COMSTA0 & 0x40) == 0x00); // Wait for Tx buffer empty bit to be se
// }
/************************************************************************************************/
if(bSendResultToUART)
{
COMTX = RecDataTemp+1;
while ((COMSTA0 & 0x40) == 0x00); // Wait for Tx buffer empty bit to be set
bSendResultToUART = 0;
}
}
}
void IRQ_Handler(void) __irq
{
IRQSTATUS = IRQSTA; // Read off IRQSTA register
ucCOMIID0 = COMIID0; // Read the UART IRQ ID register
// if ((IRQSTATUS & BIT11) == BIT11) //UART interrupt source
{
// if ((ucCOMIID0 & 0x4) == 0x4) // Receive buffer Full
{
RecDataTemp = COMRX; // read COMRX register
bSendResultToUART = 1; // Set flag to return a string to the PC
}
}
}
有用过的朋友,帮忙分析啊