Electrical – single or multiple interrupt handlers in stm32

interruptskeilstm32stm32cubemxtruestudio

I am coming from 8-bit world to 32-bit world specifically stm32f103.

At present I am only doing study and discussion with my fellows to know the major differences in the two worlds and also to select the IDE/compiler for myself.

  1. Some fellows told me that stm32 have single interrupt handler routine. For example if there are 8 timers then there will be 1 ISR and once I am inside that ISR then I will check each timer to figure out which timer has triggered the interrupt.

  2. Some fellows told me that it is IDE/compiler dependent. If I use Keil then i can use individual ISR for each Timer while if I use Truestudio/Cubemx then there will be 1 ISR as in case-1 above.

Can anyone clarify this?

Best Answer

Some fellows told me that stm32 have single interrupt handler routine.

Definitely false. Look up the Interrupts and Events chapter in the Reference Manual, there are about 60 interrupt handlers.

There are a few instances where more peripherals share a single interrupt handler, but these are rather the exception than the rule.

There are ARM microcontrollers with a single interrupt handler (or rather 2, IRQ and FIQ), but the Cortex-M family has lots of them.

For example if there are 8 timers then there will be 1 ISR and once I am inside that ISR then I will check each timer to figure out which timer has triggered the interrupt.

Each timer has its own handler, the advanced timers TIM1 and TIM8 have some more for various event types. There is a tiny grain of truth however, as timers have a common interrupt vector for all (up to 4) of their channels, so the reading of a single status register can be necessary.

If I use Keil then i can use individual ISR for each Timer while if I use Truestudio/Cubemx then there will be 1 ISR as in case-1 above.

Interrupt handling does not depend on the compiler. You don't even have to declare the interrupt handler as such, they can be ordinary C functions taking no parameters and returning nothing (void), as the necessary register saving and restoring is handled by the hardware.

The source of the confusion might be HAL library shipped with CubeMX, which has common handler and callback functions for each peripheral type, passing around so-called handles with state information. You don't have to use HAL, you'd get by fine with the descriptions of using each peripheral in the Reference Manual.