2013-04-26 02:49 AM
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 madevoid 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-interrupt2013-04-26 03:20 AM
...and I'm assuming SysTick does not need clearing
2013-04-26 05:02 AM
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.