cancel
Showing results for 
Search instead for 
Did you mean: 

NVIC Interrupts from multiple Sources - are they indepentend?

Andreas Zeiler
Associate II
Posted on June 13, 2018 at 16:29

Hi,

I use a STM32F469 which has several timers. I need to configure the NVIC Interrupts for them.

I wonder if I am still able to use for example TIMER1 & TIMER9 at the same time, as they have the same IRQ Source from the NVIC for TIM1_Break & TIM9_Global ?

If I can use them at the same time, how do I need to implment the IRQ Handler? Do I need to check on the Status Registers of the coresponding Timer IRQ?

What is the Global IRQ for Timer1 & Timer8 ? The have several IRQs...

Thanks & kind regards

Andreas

4 REPLIES 4
Posted on June 13, 2018 at 21:41

For interrupt vectors supporting multiples source you should check for ALL of them and dispatch based on source.

ie

if (TIMX->SR & x)

  Service_TIMX();

if (TIMY->SR & y)

  Service_TIMY();

Don't use IF/THEN/ELSE, multiple can signal, if you don't clear them it will re-enter, repeatedly.

Depends what you mean by global, simpler TIM have the Update and CC dump to a single vectors (TIMX_IRQHandler), the more complex use Update, CC, BREAK, etc.

Pretty sure the startup_stm32f469.s is a good reference, and it's broken down in either the DM or RM

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Alan Chambers
Associate II
Posted on June 13, 2018 at 23:01

I prefer to implement ISRs together with the rest of the driver for a given peripheral, so I generally add further weak ISR definitions as indirection to split out the calls. Something like:

    void TIM1_BRK_TIM9_IRQHandler() // Appears in the vector table

    {

        TIM1_BRK_IRQHandler(); // Weakly linked so you can

                               // re-implement elsewhere if necessary.

        TIM9_IRQHandler();     // ditto.

    }

This suffers a little because the default sub-handlers can't be

{ while (true) }

, in case you re-implement only one of them, but that's never been an issue.

I've also dabbled with implementing the sub-handlers as an array of assignable callbacks. This allows drivers to implement any function they like to handle interrupts, and assign them to the relevant IRQ by index. This means drivers can be quite agnostic about which particular interrupts they are using.
Andreas Zeiler
Associate II
Posted on June 14, 2018 at 10:38

Hi,

thanks!

Ok, I assume that I can use all Timers at once.

I just need to check how I will put the handlers together with the processes which handles the irqs itself.

Kind regards

Andreas

Posted on June 14, 2018 at 11:24

cool stuff,

yes they will all run in parallel,

make sure you are in and out of your interrupts within 10-20uS

best to declare a global table, and fill it from the interrupt.

check for the flags in a foreground process, say every mS.