2018-02-22 03:55 PM
I'm new to programming with ST Micro, so I hope this is a simple question.
Here is the generic pattern (correct me if I'm wrong) in an IRQ handler:
void EXTI4_IRQHandler(void)
{ if(EXTI_GetITStatus(EXTI_Line4) != RESET) {/* Execute your code here */
/* Clear the EXTI line 4 pending bit */ EXTI_ClearITPendingBit(EXTI_Line4); }}What happens if my external line interrupts at a high rate, maybe it's noisy?
Do I have to worry that I may enter this handler with another interrupt before I've finished servicing the first one? I'd probably need to use a mutex or equivalent if I don't want to service two interrupts at once.
OR.... am I guaranteed not to get another interrupt until after I clear the pending bit?
#my-irq-question2018-02-23 12:29 AM
Do I have to worry that I may enter this handler with another interrupt before I've finished servicing the first one?
...
OR.... am I guaranteed not to get another interrupt until after I clear the pending bit?
Not exactly.
The so-called tail chaining happens, you reenter the handler as soon as you exit it.
Other interrupts with higher priority might preempt your handler, though.
What happens if my external line interrupts at a high rate, maybe it's noisy?
You will enventually choke your system.
The best solution is to filter the noise with hardware, before it creates interrupts.
Had such an issue with an old project, when the device was exposed to noisy environment.
The device was virtually blocked, and the only solution had been to disable interrupts periodically.
However, this resulted in guaranteed communication losses.
2018-02-23 01:45 AM
AvaTar wrote:
filter the noise with hardware, before it creates interrupts.
Absolutely.
This has nothing specifically to do with STM32 - it would be the same on
any
chip if you trigger an interrupt faster than the chip can actually handle those interrupts.Another option would be to poll the input at a suitable rate - and possibly add some 'filtering' in software...
Again, a standard technique -
nothing specific to STM32
2018-02-23 01:58 AM
Another option would be to poll the input at a suitable rate - and possibly add some 'filtering' in software...
Again, a standard technique -
nothing specific to STM32
+1
Filtering can be also added in hardware, either real external filter, or using the timers' inputs filtering facility.
JW