cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Interrupts: Clearing and related questions.

bl
Associate II
Posted on April 26, 2013 at 11:49

Hi 

Just some general questions on interrupts:

I assume that external interrupts need to be be cleared. There are some forum threads that are suggesting that this is done ''automatically'' and it does not need to be coded. I'm going with  something like this (assuming that they do need to be cleared)

extern ''C'' void EXTI4_IRQHandler()

    {

    if (EXTI_GetITStatus(EXTI_Line4 ) != RESET)

{

EXTI_ClearITPendingBit(EXTI_Line4 );

NowDoSomethin();

}

    }

Also tracing back the EXTI_ClearITPendingBit function into the ST lib I see that there is also a clear Flag call that can be made

void EXTI_ClearFlag(uint32_t EXTI_Line);

void EXTI_ClearITPendingBit(uint32_t EXTI_Line);

Is clearing the bit the right way to go and when would the ClearFlag be used??

#stm32f4-irq-interrupt
2 REPLIES 2
bl
Associate II
Posted on April 26, 2013 at 12:20

...and I'm assuming SysTick does not need clearing

Posted on April 26, 2013 at 14:02

Well you definitely want to clear the EXTI interrupt latch, and consider what the source is doing, is it still asserting or temporal.

Situations where you don't need to explicitly clear the interrupt are the USART, where reading/writing the DR is sufficient to clear the driving source.

It's the source on the peripheral, not the NVIC, which needs clearing, how that works depends on the peripheral and how it gates/latches it's internal interrupt sources.

Correct, SysTick does not need clearing, it's classed as a System Handler

Also consider when you clear the interrupt, there is a race condition with the NVIC and tail-chaining due to write buffers, and pipelining. Clear the source early in the service routine, not immediately before you leave.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..