Skip to main content
Graduate
November 10, 2024
Question

Disabling interrupts and clearing flags (TIM8 CC4) - Only working when interrupts are enabled?

  • November 10, 2024
  • 1 reply
  • 2050 views

I have quite a complicated case, where a interrupt is beeing executed, allthough it has been disabled, and its flag beeing cleared. At the same time interrupts are disabled, and i put a few nops in between just to rule out any delay related issues. The disabling of the interrupt works, but there is just one afterwards that i cant get rid of.

For now i just would like to know, if anyone has any idea if the title can be answered with yes. (And if there is a explanation why that is)

I would have liked to try a minimal code, but its quite complicated and i am afraid the error can then not be reproduced. Timers are interconnected too.

    This topic has been closed for replies.

    1 reply

    Super User
    November 10, 2024

    If you disable the interrupt at the source (e.g. in TIMx_DIERx), it takes time until this gets propagated into NVIC.

    There may be a strange effect with the interrupt "reappearing" in NVIC, if it was cleared too soon after disabling the interrupt source.

    JW

    TobeAuthor
    Graduate
    November 10, 2024

    This is how i clear it:

    CLEAR_BIT(TIM8->DIER, TIM_DIER_CC4IE);

    30 NOP´s

    TIM8->SR = ~TIM_SR_CC4IF;

    30 NOP´s

    other code

    SET_BIT(TIM8->EGR, TIM_EGR_COMG); //should not matter here

    delayMicros(2);

    When i enable interrupts before the delay, the interrupt does not get fired again, if i enable interrupts after, it does get fired again. See the picture for timing illusatration:

    • PC4 is the actual clearing (first 5 lines of code above).
    • PB11 is the problem interrupt
    • Pink lines show interrupt times
    • PA12 is the interrupt, that (should) disables the problem interrupt
    • Ignore the "IRQ Disabled" channel, as it has some issue and is not valid
    Super User
    November 10, 2024

    There is no direct relationship between commutation event and CC4 event, so it can't be judged from this description without knowing your entire program.

    JW