Skip to main content
robertpettersson9
Associate
March 29, 2010
Question

Dual Interrupts from single UEV on TIM1 (STM32f103 )

  • March 29, 2010
  • 4 replies
  • 907 views
Posted on March 29, 2010 at 15:27

Dual Interrupts from single UEV on TIM1 (STM32f103 )

    This topic has been closed for replies.

    4 replies

    Tesla DeLorean
    Guru
    May 17, 2011
    Posted on May 17, 2011 at 13:45

    void TIM2_IRQHandler()

    {

        if (TIM_GetITStatus(TIM2, TIM_IT_Update) == SET)

        {

            TIM_ClearITPendingBit(TIM2, TIM_IT_Update);

            // toggle bit

            GPIOC->ODR ^= GPIO_Pin_12;

        }

    }

    >>If you're clearing it at the ''end'', maybe it's calling the ISR again (the double) before it gets the clear bit set...

    You'd have to be doing a lot of stuff, but it will have longer to clear before exiting and being checked again.

    Perhaps the better way to attack this is to see which of the 8 interrupts is pending, and make sure that they are ALL cleared. If interrupts aren't cleared on the STM32 you basically get a crap storm of interrupts and it won't execute any user space code.

    -Clive
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    kamputty
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 13:45

    Are you clearing the interrupt at the ''start'' of the ISR or at the ''end''?

    For example, in my TIM ''Hello world'', I use this...

    void TIM2_IRQHandler()

    {

        TIM_ClearITPendingBit(TIM2, TIM_IT_Update);

        // toggle bit

        GPIOC->ODR ^= GPIO_Pin_12;

    }

    If you're clearing it at the ''end'', maybe it's calling the ISR again (the double) before it gets the clear bit set...

    robertpettersson9
    Associate
    May 17, 2011
    Posted on May 17, 2011 at 13:45

    Problem solved!

    robertpettersson9
    Associate
    May 17, 2011
    Posted on May 17, 2011 at 13:45

    Gentlemen, thanks a lot!!!

    You were right, the ISR was called multiple times due to my clearing of the IRQ in the end of my code.

    I discovered it also when I unintentionally forgot to clear the IRQ, then I got a crazy amount of calls to my ISR, but at the time I couldnt fully understand it.