Question
Interrupt pending registers not cleared
Posted on December 20, 2012 at 21:50
I have a number of switches which generate interrupts. When I Flick switch A it goes from High to Low
and the A interrupt occurs(EXTI_PR is now 0x00000200 as expected). I then clear the pending register (EXTI_PR is now 0x00000000). At this time switch A is still at low which is what I require. Now while switch A is still low, I switch B from High to Low. Instead of entering the B interrupt routine, which is what I expect, the processor still enters the A routine. I can understand this because when I check EXTI_PR, its value is 0x00000600. How can I avoid this situation? I need to keep A switched low while B is switched. I would not have expected this as the interrupts are edge triggered. What is keeping the pending registers from being properly cleared? The pending register only changes to 0x00000400 when I switch A on and off. When I activate the switches by flicking them ON and OFF, the interrupts behave accordingly. However, my system doesn't allow this. I appreciate any help. Bob /* Configure PC9 pin as input floating */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9|GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOC, &GPIO_InitStructure); /* Connect EXTI0 Line to PC9 pin */ SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource9); /* Connect EXTI0 Line to PC10 pin */ SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource10); /* Configure EXTI9 line */ EXTI_InitStructure.EXTI_Line = EXTI_Line9; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* Configure EXTI10 line */ EXTI_InitStructure.EXTI_Line = EXTI_Line10; EXTI_Init(&EXTI_InitStructure); /* Enable and set EXTI4_15 Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = EXTI4_15_IRQn; NVIC_InitStructure.NVIC_IRQChannelPriority = 0x00; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); void EXTI4_15_IRQHandler(void) { if(EXTI_GetITStatus(EXTI_Line9) != RESET) { printf(''\n\r Interrupt A''); EXTI_ClearITPendingBit(EXTI_Line9); } else if (EXTI_GetITStatus(EXTI_Line10) != RESET) { printf(''\n\r Interrupt B''); EXTI_ClearITPendingBit(EXTI_Line10); } }