我有两个外部中断源进入STM32F105。我想要其中一个(称之为“IRQHigh”)来抢占另一个(“IRQLow”)。目前,如果在IRQLow ISR期间触发IRQHigh,程序流将等待,直到我清除IRQLow ITPending位,然后才分支到IRQHigh ISR。STM32F105是基于Cortex-M3的微控制器。它支持嵌套中断。我的应用程序是用C语言编写的,使用Eclipse中的GCC(ARM-none-eabi-gcc)和STM32F1标准外设库。我认为我已正确配置优先级但我必须遗漏一些东西。
这是相应的初始化代码。我已经删除了AFB时钟命令,GPIO配置等,因为每个子系统似乎都能正常工作:- <font size="4">#define IRQHIGH_EXti_PORT GPIO_PortSourceGPIOA
- #define IRQHIGH_EXTI_PIN GPIO_PinSource3
- #define IRQHIGH_EXTI_LINE EXTI_Line3
- #define IRQHIGH_EXTI_IRQn EXTI3_IRQn
- #define IRQLOW_EXTI_PORT GPIO_PortSourceGPIOC
- #define IRQLOW_EXTI_PIN GPIO_PinSource11
- #define IRQLOW_EXTI_LINE EXTI_Line11
- #define IRQLOW_EXTI_IRQn EXTI15_10_IRQn
- NVIC_InitTypeDef NVIC_InitStructure;
- EXTI_InitTypeDef EXTI_InitStructure;
- // Sixteen levels of pre-emption priority, no subpriorities
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
- // IRQHigh
- // Connect EXTI Line to GPIO Pin
- GPIO_EXTILineConfig(IRQHIGH_EXTI_PORT, IRQHIGH_EXTI_PIN);
- // Configure EXTI line
- EXTI_InitStructure.EXTI_Line = IRQHIGH_EXTI_LINE;
- EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
- EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
- EXTI_InitStructure.EXTI_LineCmd = ENABLE;
- EXTI_Init(&EXTI_InitStructure);
- // Configure and enable EXTI Interrupt
- NVIC_InitStructure.NVIC_IRQChannel = IRQHIGH_EXTI_IRQn;
- NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
- NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
- NVIC_Init(&NVIC_InitStructure);
- // IRQLow
- // Connect EXTI Line to GPIO Pin
- GPIO_EXTILineConfig(IRQLOW_EXTI_PORT, IRQLOW_EXTI_PIN);
- // Configure EXTI line
- EXTI_InitStructure.EXTI_Line = IRQLOW_EXTI_LINE;
- EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
- EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
- EXTI_InitStructure.EXTI_LineCmd = ENABLE;
- EXTI_Init(&EXTI_InitStructure);
- // Configure, but do not enable, EXTI Interrupt
- NVIC_InitStructure.NVIC_IRQChannel = IRQLOW_EXTI_IRQn;
- NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 5;
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
- NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;
- NVIC_Init(&NVIC_InitStructure);</font>
复制代码IRQ处理程序设置如下:- <font size="4">void EXTI3_IRQHandler(void)
- {
- IRQHigh();
- EXTI_ClearITPendingBit(IRQHIGH_EXTI_LINE);
- }
- void EXTI15_10_IRQHandler(void)
- {
- if (EXTI_GetITStatus(IRQLOW_EXTI_LINE) == SET)
- {
- if (IRQLow()) // This returns a non-zero value if an overflow happened
- {
- CleanUpOverflow();
- }
- // Clear interrupt bit.
- EXTI_ClearITPendingBit(IRQLOW_EXTI_LINE);
- }
- else // unknown EXTI source
- {
- ErrorHandler(ERR_UNKNOWN_EXTI15_10_IRQ); // This never happens
- }
- }</font>
复制代码
一些注意事项:- IRQHigh()和IRQLow()每个都需要很长时间才能完成(这就是为什么我想让一个人打断另一个)
- IRQLow最初未启用,但已启用 NVIC_EnableIRQ(IRQLOW_EXTI_IRQn);
- 在EXTI15_10_IRQHandler()中,我从IRQLow()获得一个返回值。
- 我已经声明了xxx_IRQHandler()函数__attribute__ ((interrupt ("IRQ")))。我知道Cortex-M3不需要这个属性,但无论如何我都尝试了(并得到了相同的结果)。
我究竟做错了什么?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>