2012-12-13 04:00 AM
Hi,
I wonder if C compiler has to know that the given function is an interrupt handler. Looking at the sample code I see not pragmas or any other ways to tell compiler about it. From the other side as far as I could understand Cortex-M3 documentation Interrupt Controller does not save all registers in stack before call to IRQ handler so it is not clear to me how damaging of other not saved registers is prevented?Thanks.2012-12-13 04:52 AM
''I wonder if C compiler has to know that the given function is an interrupt handler''
No. That is one of the specific design features of the ARM Cortex-M architecture. eg,
http://www.arm.com/files/pdf/CortexM3_Uni_Intro.pdf
- see foot of p5''Looking at the sample code I see not pragmas or any other ways to tell compiler about it'' Correct.''Interrupt Controller does not save all registers in stack before call to IRQ handler so it is not clear to me how damaging of other not saved registers is prevented?''The Interrupt Controller saves only enough registers so that the Compiler doesn't have to save any extra registers in addition to what it does for all functions.
2014-04-08 04:50 AM
You can't name your interrupt handler function arbitrarily (though the content of the function is up to you, of course). There's only a fixed set of interrupts acquired by the processor with their names being preset. You have to call interrupt handler function in accordance with the interrupt it has to handle, e.g. void TIM1_UP_TIM10_IRQHandler(void) for the function treating TIM10 update event. The names available are listed in 'stm32f4xx.c ' file.
2014-04-08 06:20 AM
You can't name your interrupt handler function arbitrarily..
You could if you really wanted too. The names stored via the vector table are in startup_stm32fxx.s2014-04-08 06:41 AM
Interrupt handler names are purely arbitrary in the sense that there are pre-defined names in the untime startup routines from ST and CMSIS. But there's one good reason to change the names in the startup file and that's when a reentrant interrupt handler is used for multiple units of the same peripheral, for instance USART, SPI, CAN, I2C, as well as DMA and timers. I use reentrant handlers frequently so I have a heavily modified runtime startup.
Jack Peacock2014-04-08 11:29 AM
''You can't name your interrupt handler function arbitrarily''
Oh Yes YouCan
!The names are entirely irrelevant as far as the chip is concerned - it neither knows nor cares anything of them.The names are entirely arbitrary to as far as the compiler is concerned.The restriction only comes if you want to be compatible with some existing source code - such as the 'stm32f4xx.c ' file provided by ST. But the names used there are entirely arbitrary.