2012-03-28 10:30 PM
2012-03-29 06:11 AM
Although the UM says that almost all pins on all ports can be used as EXTIs, there are only 5 EXTI IRQs. There does not seem to be an explicit way to map a pin to an ISR, so is it the case that only pins 0..4 on a port can be used for EXTI?
No, it means that some of your EXTI interrupt handlers (5-9) and (10-15) will need to differentiate the source as the first step of processing/dispatching the request.2012-03-30 10:57 AM
Thanks for pointing me in the right direction, Clive.
I had seen the first five handlers:EXTI0_IRQHandler ; EXTI
Line0
EXTI1_IRQHandler ; EXTI Line1
EXTI2_IRQHandler ; EXTI Line2
EXTI3_IRQHandler ; EXTI Line3
EXTI4_IRQHandler ; EXTI Line4
... but I missed the other two:
EXTI9_5_IRQHandler ; External Line[9:5]s
EXTI15_10_IRQHandler ; External Line[15:10]s
For the benefit of anyone else in the same situation, I've stripped the relevant code out of my app. I believe it is complete, but I have not tested the isolated fragment.
Curiously, my EXTI3 interrupt worked fine without enabling the SYSCFG clock.
void config(void){
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
/* SYSCFG clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
/* external int config register is in SYSCFG */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource12);
/* GPIOB clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
/* configure GPIO pin as input */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* configure PB12 as interrupt on falling edge */
EXTI_InitStructure.EXTI_Line = EXTI_Line12;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Configure and enable EXTI interrupt on PB12 */
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void EXTI15_10_IRQHandler(void){
// did we get here due to falling edge on PB12
if(EXTI_GetITStatus(EXTI_Line12)){
EXTI_ClearITPendingBit(EXTI_Line12);
}else if( /* test for another interrupt */){
}
}