2021-10-14 11:40 PM
Hello,
I'm using an stm32f411ce with an lsm6ds3 IMU and I want to trigger a read from the IMU with an EXTI. I've set it all in the code below and activated the interrupt on the IMU. the interrupt is set in PR register but handler is never called.
Thanks,
Eyal
void EXTIsetup(void)
{
//PB3 ---- IMU INT1 gyro
//PB12 --- IMU INT2 accel
//PB0 ---- BAR INT
//1. Enable the SYSCFG/AFIO bit in RCC register
//2. Configure the EXTI configuration Register in the SYSCFG/AFIO
//3. Disable the EXTI Mask using Interrupt Mask Register (IMR)
//4. Configure the Rising Edge / Falling Edge Trigger
//5. Set the Interrupt Priority
//6. Enable the interrupt
RCC ->AHB1ENR |= (1 << 1); //enable the GPIOB bus clock
//set the moder values
//GPIOB ->MODER &= ~(3 << 0);
GPIOB ->MODER &= ~(3 << 6);
//GPIOB ->MODER &= ~(3 << 24);
//set pull down on all three pins
//GPIOB ->PUPDR |= (1 << 1);
GPIOB ->PUPDR |= (1 << 7);
//GPIOB ->PUPDR |= (1 << 25);
RCC ->APB2ENR |= (1 << 14); //enable SYSCNFG
//SYSCFG ->EXTICR[0] |= (1 << 0); //EXTI0 --> PB PB0
SYSCFG ->EXTICR[0] |= (1 << 12); //EXTI3 --> PB PB3
//SYSCFG ->EXTICR[3] |= (1 << 0); //EXTI12 --> PB PB12
//EXTI ->IMR |= (1 << 0); //dsb mask MR0
EXTI ->IMR |= (1 << 3); //dsb mask MR3
//EXTI ->IMR |= (1 << 12); //dsb mask MR12
//EXTI ->RTSR |= (1 << 0); //enable rising edge on line 0
EXTI ->RTSR |= (1 << 3); //enable rising edge on line 3
//EXTI ->RTSR |= (1 << 12); //enable rising edge on line 12
//EXTI ->FTSR &= ~(1 << 0); //disable falling edge on line 0
EXTI ->FTSR &= ~(1 << 3); //disable falling edge on line 3
//EXTI ->FTSR &= ~(1 << 12); //disable falling edge on line 12
//setting the priority of the interrupts
NVIC_SetPriority(EXTI3_IRQn, 1);
//NVIC_SetPriority (EXTI4_IRQn, 1);
//enable the interrupts
NVIC_EnableIRQ(EXTI3_IRQn);
//NVIC_EnableIRQ(EXTI4_IRQn);
}
Solved! Go to Solution.
2021-10-15 11:22 AM
that is the handler implementation.
does it seem fine?
2021-10-15 12:12 PM
C++?
JW
2021-10-15 12:15 PM
not sure what you mean but I am using C++
2021-10-15 12:23 PM
So it has C++ linkage, not C linkage, which means the linker doesn't see it as EXTI3_IRQHandler.
To fix, surround it in extern "C" braces.
extern "C" {
void EXTI3_IRQHandler() {
...
}
}
2021-10-15 12:25 PM
OK thanks.
the whole main file is cpp. does it still matter?
2021-10-15 12:28 PM
It works now! thank you very much
2021-10-15 12:35 PM
2021-10-15 10:26 PM
ok now I get it thanks!