I have problem with my Nucleo F401RE: When i'm trying to trigger interrupt by changing value on PA9, nothing happens :(
My code:
void EXTI_Config(){
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA,EXTI_PinSource6);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA,EXTI_PinSource7);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA,EXTI_PinSource8);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA,EXTI_PinSource9);
EXTI_InitTypeDef buttonEXTI;
EXTI_StructInit(&buttonEXTI);
buttonEXTI.EXTI_Line = 0x1E0;
buttonEXTI.EXTI_Mode = EXTI_Mode_Interrupt;
buttonEXTI.EXTI_Trigger = EXTI_Trigger_Rising;
buttonEXTI.EXTI_LineCmd = ENABLE;
EXTI_Init(&buttonEXTI);
NVIC_InitTypeDef buttonNVIC;
buttonNVIC.NVIC_IRQChannel = EXTI9_5_IRQn;
buttonNVIC.NVIC_IRQChannelPreemptionPriority = 1;
buttonNVIC.NVIC_IRQChannelSubPriority = 0;
buttonNVIC.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&buttonNVIC);
EXTI_ClearFlag(0x1E0);
}
void EXTI9_5_IRQHandler(){
if(EXTI_GetFlagStatus(EXTI_Line6)==SET){ //works
EXTI_ClearITPendingBit(EXTI_Line6);
if (mode==0&&isTimeSet){
mode=1;
} else if(mode==1){
mode=2;
} else {
mode=1;
}
} else if (EXTI_GetFlagStatus(EXTI_Line7)==SET){ //works
EXTI_ClearITPendingBit(EXTI_Line7);
changeValue=2;
} else if (EXTI_GetFlagStatus(EXTI_Line8)==SET){ //works
EXTI_ClearITPendingBit(EXTI_Line8);
changeValue=1;
} else if (EXTI_GetFlagStatus(EXTI_Line9)==SET){ //don't work :(
EXTI_ClearITPendingBit(EXTI_Line9);
settingsApplied=1;
}
}
Every other interrupt works like charm, but this one - don't. In schematics of board this pin is not plugged, so I don't know why this happening :(
I suppose problem in the following line
your mask must be 0x03C0
to avoid similar mistakes you can use the following method: