2014-12-14 05:21 AM
Hello,
I've got a strange problem with setting an interrupt for input pins on my Nucleo board. Actualy, no one interrupt except EXTI15_10_IRQn doesn't work. I'm attaching two portions of code, one using input pin 10 and EXTI15_10_IRQn works well, and the second one using pin 9 and EXTI9_5_IRQn doesn't work at all. Would anybody be so kind to point me what is wrong? Actualy I've tried all EXTI lines (from B0 to B15) with using of corresponding pins and EXTI lines and got working only pins B10-B15. No interrupts from other pins were obtained.Thanks in advanceLeonid-------------------------- WORKING CODE---------------------------------//Initializationvoid SetACInterrupts(void){ EXTI_InitTypeDef EXTI_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; /* Connect Button EXTI Line to Button GPIO Pin */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource10); /* Configure Button EXTI line */ EXTI_InitStructure.EXTI_Line = EXTI_Line10; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* Enable and set Button EXTI Interrupt to the lowest priority */ //Selecting the channel depending on Pin number NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure);}
//Handlervoid ACZeroHandler(void);void EXTI15_10_IRQHandler(void){ ACZeroHandler();}-------------------------- NOT WORKING CODE-------------------------//Initializationvoid SetACInterrupts(void){ EXTI_InitTypeDef EXTI_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; /* Connect Button EXTI Line to Button GPIO Pin */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource9); /* Configure Button EXTI line */ EXTI_InitStructure.EXTI_Line = EXTI_Line9; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* Enable and set Button EXTI Interrupt to the lowest priority */ //Selecting the channel depending on Pin number NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure);}//Handler. Never to be called!void EXTI9_5_IRQHandler(void); void EXTI9_5_IRQHandler(void){ ACZeroHandler();} #exti-interrupt-error2014-12-14 08:19 AM
Using .cpp?
How are pins configured?2014-12-15 12:41 AM
No C++ usage, pure C project (Atolic). Pins are configured as inputs. Pin configuration code is located in other function, and it was same for all pins used. Acualy, all GPIOB pins are configured identically as inputs (NOPUPP, PP, 40 MHz) and all of them works fine in terms of reading of incoming data. The problem is - only pins 10 to 15 genertes an interrupt. Looks like system doesn't see handler for other EXTI lines.
I've noticed the fact - EXTI15_10 is in use by sample code for user input button on Nucleo board. I've removed user button configuration code from my project, but maybe where were some additional configuration steps I haven't detected and they makes EXTI15_10 work in my code... All conditions2014-12-15 01:39 AM
At a glance your code doesn't look unreasonable. I don't have specific experiences with the Nucleo L152 board, but other STM32 work and route the EXTI signals appropriately.
Might want to double check the startup file, the vectors therein, and the .MAP file linkage of the IRQHandler