我的UCOS无法进FIQ中断,困扰一周了,请大伙看看问题出在哪!
UCOS是下载的官方的源码,在IAR上移植好的.我在上面加了中断,加中断的方法和在单任务下的一样:串口0,串口1的初始化和中断设置
void Usart_init ( void ) { AT91C_BASE_PIOA-> PIO_PDR= (AT91C_PA0_RXD0) |(AT91C_PA1_TXD0 ); AT91F_PIO_CfgPullup(AT91C_BASE_PIOA, (AT91C_PA0_RXD0) |(AT91C_PA1_TXD0 )); // First, enable the clock of the USART AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1 << AT91C_ID_US0 ) ; // Usart Configure AT91F_US_Configure (AT91C_BASE_US0, AT91B_MCK, AT91C_US_ASYNC_MODE, AT91_BAUD_RATE, 0); // Enable usart AT91C_BASE_US0->US_CR = AT91C_US_RXEN | AT91C_US_TXEN;
//* Enable USART IT error and RXRDY //AT91F_US_EnableIt(AT91C_BASE_US0,AT91C_US_TIMEOUT | AT91C_US_FRAME | AT91C_US_OVRE |AT91C_US_RXRDY); AT91F_US_EnableIt(AT91C_BASE_US0,AT91C_US_RXRDY); //* open Usart 0 interrupt AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, AT91C_ID_US0, USART_INTERRUPT_LEVEL,AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, Usart0_c_irq_handler); AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_US0);
AT91C_BASE_PIOA->PIO_PDR= (AT91C_PA5_RXD1) |(AT91C_PA6_TXD1 ); AT91F_PIO_CfgPullup(AT91C_BASE_PIOA, (AT91C_PA5_RXD1) |(AT91C_PA6_TXD1 )); // First, enable the clock of the USART AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1 << AT91C_ID_US1 ) ; // Usart Configure AT91F_US_Configure (AT91C_BASE_US1, AT91B_MCK, AT91C_US_ASYNC_MODE,9600, 0);
// Enable usart AT91C_BASE_US1->US_CR = AT91C_US_RXEN | AT91C_US_TXEN;
//* Enable USART IT error and RXRDY //AT91F_US_EnableIt(AT91C_BASE_US1,AT91C_US_TIMEOUT | AT91C_US_FRAME | AT91C_US_OVRE |AT91C_US_RXRDY); AT91F_US_EnableIt(AT91C_BASE_US1,AT91C_US_RXRDY); //* open Usart 1 interrupt AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, AT91C_ID_US1, USART1_INTERRUPT_LEVEL,AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, Usart1_c_irq_handler); AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_US1); #ifdef LOCAL_DEBUG DBGU_WrStr("
USART initialization ok!!
"); #endif }
经过测试以上代码都能正常运行,也能进中断.于是我加入了FIQ中断代码如下:
Void Fiq_Init(void) { AT91F_PIO_CfgPeriph(AT91C_BASE_PIOA,1<<29,0); AT91F_PIO_CfgInput(AT91C_BASE_PIOA, 1<<29); AT91F_PIO_InputFilterEnable(AT91C_BASE_PIOA, 1<<29); AT91F_PIO_CfgPullup(AT91C_BASE_PIOA, 1<<29); AT91F_AIC_ConfigureIt(AT91C_BASE_AIC , AT91C_ID_FIQ,FIQ_INTERRUPT_LEVEL,AT91C_AIC_SRCTYPE_EXT_NEGATIVE_EDGE, FIQ_init_handler ); AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_FIQ); // generate FIQ interrupt by software AT91F_AIC_Trig (AT91C_BASE_AIC,AT91C_ID_FIQ) ; } 用7X256的PA29的外设A,即FIQ,有下降沿触发中断.这个函数在单任务下运行没问题.但移植到UCOS中后,执行到AT91F_AIC_Trig (AT91C_BASE_AIC,AT91C_ID_FIQ) ;就会死机,先将该句屏蔽. 开始仿真发现下降沿来临时触发了中断,程序跳转到了OS_CPU_A.ASM中的OS_CPU_ARM_EXCEPT_FIQ_HANDLER,执行FIQ的相关处理.然后执行OS_EXCEPT_HANDLER ,但没有执行我定义的FIQ_init_handler()函数. 另外仿真时有跳转到OS_CPU_ARM_EXCEPT_DATA_ABORT_HANDLER的情况.
OS_EXCEPT_HANDLER (CPU_INT32U except_id)在OS_CPU_A.ASM中调用时,其参数except_id是怎么确定的?
如果不让UCOS管理FIQ中断应怎样设置呢?
请各位帮帮忙!!谢谢
|