打算设计使用ssc传输数据,ssc采用loop模式,发和收管脚连接。在不采用dma和中断时候,寄存器收发都是正常的,采用DMA形式,数据收发也是可以的,但在采用中断触发的时候,可以进入中断函数,但是执行完,中断却不退出,感觉中断配置没问题,很费解。
下面是调试程序,请大家帮看看问题出在哪。
void AT91F_AIC_configure(void)
{
AT91PS_AIC pAIC=AT91C_BASE_AIC;
// Disable the interrupt
pAIC->FAIC_IDCR |= 1 << AT91C_ID_SSC;
// Configure mode and handler
pAIC->FAIC_SVR[AT91C_ID_SSC] = (unsigned int) SSC_handler;
pAIC->FAIC_SMR[AT91C_ID_SSC] = AT91C_AIC_SRCTYPE_EXT_NEGATIVE_EDGE|0x0;
// Clear interrupt
pAIC->FAIC_ICCR |= 1 << AT91C_ID_SSC;
}
void SSC_handler(void)
{
unsigned int receivedata;
AT91PS_SSC ssc = AT91C_BASE_SSC;
AT91PS_AIC pAIC=AT91C_BASE_AIC;
//disable aic
pAIC->FAIC_IDCR |= 1 << AT91C_ID_SSC;
if(ssc->FSSC_SR & AT91C_SSC_RXRDY)
{
receivedata=ssc->FSSC_RHR;
printf("receivedata=%x\r\n",receivedata);
}
//clear aic
pAIC->FAIC_ICCR |= 1 << AT91C_ID_SSC;
//enable aic
pAIC->FAIC_IECR |= 1 << AT91C_ID_SSC;
pAIC->FAIC_EOICR=1 << AT91C_ID_SSC;
}
void AT91F_ssc_send(unsigned int senddata)
{
AT91PS_SSC ssc = AT91C_BASE_SSC;
AT91PS_AIC pAIC=AT91C_BASE_AIC;
while ((ssc->FSSC_SR & AT91C_SSC_TXRDY) == 0);
ssc->FSSC_THR = senddata;
printf("senddata=%x\r\n",senddata);
}
void SSC_test(void)
{
AT91F_ssc_send(0x5a;
printf("had send\r\n");
}
进入中断函数SSC_handler执行完应该退出中断,但是程序不知道去了哪里,没有打印printf("senddata=%x\r\n",senddata);这句。 |