Question
Interrupt triggering twice - check for interrupt clear latency issue does not work
Hi,
i know the gotcha about the late clearing. My interrupt (yes it currently useless) is so short, that clearing in the beginning would not work either, so i tried to implement a check for the interrupt flag. But with no success: It is fired twice.
Is my approach wrong?
This is the interrupt:
/*
* Exiting interrupt with if(true)+(2 NOP´s) is about 20ns, Checking for "! (TIM8->SR & TIM_SR_COMIF)" adds 120ns!
*/
void TIM8_TRG_COM_IRQHandler(){
GPIOC->BSRR = (uint32_t) GPIO_PIN_3;
if(! (TIM8->SR & TIM_SR_COMIF)){ // Return if no flag is set (prevents false triggers because of latency in the bus)
__ASM volatile ("NOP");
__ASM volatile ("NOP");
GPIOC->BRR = (uint32_t) GPIO_PIN_3;
return;
}
TIM8->SR = ~TIM_SR_COMIF; // DONT send "&=" ReadModifyWrite is bad!
__ASM volatile ("NOP");
__ASM volatile ("NOP");
GPIOC->BRR = (uint32_t) GPIO_PIN_3;
}
