2021-11-13 02:47 AM
Hello,
I'm using an stm32f411 which is a cortex M4 device.
In my application I have an interrupt from an IMU in a 400hz frq. Every time the interrupt is called I want to read data from the sensor and process it using a filter function.
I have a few questions:
The service routine is the only code executed(there is an empty while 1).
thanks!
Eyal
2021-11-13 03:25 AM
1: Your user code gets interrupted, the IRQ runs and then returns to your user code.
2: Variables shared by user and IRQ code must be volatile or , as bad alternative, no optimazation may be used.
Make sure your user code is done when the next IRQ arrives, wait for interrupt WFI after the evaluation in user code is done.
2021-11-13 03:33 AM
Thanks for the response!
I think you misunderstood my first question. The question is what happens if the interrupt handler is running and while it happens the same interrupt is triggered.
Thanks
2021-11-13 04:38 AM
> The question is what happens if the interrupt handler is running and while it happens the same interrupt is triggered.
From the interrupt controller's point of view, most interrupts in STM32 are level-triggered, i.e. there is some status register bit (e.g. bits in TIMx_SR for timer interrupts) which gets set when the interrupt source "happens", and which must be cleared in the interrupt service routine (ISR) otherwise ISR will be entered again and again.
If the new interrupt "happens" before ISR clears given bit, that bit is already set so the new "occurence" of interrupt is ignored. If it "happens" after ISR clears given bit, that bit gets set again and causes the ISR to be re-entered immediately after it exits.
JW
2021-11-13 05:01 AM
OK I get it thanks!
in the handler I'm turning off the bit only at the end of the routine.
is it alright?
2021-11-13 07:45 AM
Is it alright? When you need ignore next occurence in service time , then YES otherwise no and need clear ASAP.
Or better in teory multiple interrupt possible in service time is create only increment variable in ISR and main while execute servicing and decrement...
2021-11-13 12:08 PM
OK thanks!
In my application I just want the code to run as fast as possible so it doesn't matter if the interrupt is ignored