We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
Newbie trying to make multiple interrupts work! I have been playing with the STM32-Discovery board and I am trying to make multiple interrupt handlers work at the same time. I am able to execute one interrupt, but I can’t get others to work.
The first interrupt handler is based on the blue button (PA0) (Code: see ButtonInit() in www.embedds.com/.../ ); it works great!
I want an other interrupt line and so I have picked PA4 and I have made the following changes:
void newInterrupt() { //EXTI structure to init EXT EXTI_InitTypeDef EXTI_InitStructure; //NVIC structure to set up NVIC controller NVIC_InitTypeDef NVIC_InitStructure; //Connect EXTI Line to Button Pin GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource4); // <------ CHANGE 1 //Configure Button EXTI line EXTI_InitStructure.EXTI_Line = EXTI_Line4; // <------ CHANGE 2 //select interrupt mode EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; //generate interrupt on rising edge EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //enable EXTI line EXTI_InitStructure.EXTI_LineCmd = ENABLE; //send values to registers EXTI_Init(&EXTI_InitStructure); //configure NVIC //select NVIC channel to configure NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn; //<------- CHANGE 3 //set priority to lowest NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; //set subpriority to lowest NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; //enable IRQ channel NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //update NVIC registers NVIC_Init(&NVIC_InitStructure); }
I made 3 changes (see above) and I can’t get it to work. If I understand the interrupt mechanism correctly, PA4 maps to EXTI4; whose signal is mapped onto the “EXTI1_IRQn” line because EXTI4 resides on AFIO_EXTOCR2 (EXTI0 resides on AFIO_EXTOCR1 and so its EXTI0_IRQn... the example sticks to this and it works). Is my understanding correct? Whats wrong with the above code and how can I make it work. Any suggestions are highly appreciated.
Thanks, Pradeep