cancel
Showing results for 
Search instead for 
Did you mean: 

Handling multiple interrupts (noisy line)

Mark Senko
Associate
Posted on February 23, 2018 at 00:55

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-question
3 REPLIES 3
AvaTar
Lead
Posted on February 23, 2018 at 09:29

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.

Posted on February 23, 2018 at 09:45

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

Posted on February 23, 2018 at 09:58

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