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.
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.
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.