cancel
Showing results for 
Search instead for 
Did you mean: 

Where are _IRQHandler functions defined?

Shahriar Sayeed
Associate
Posted on March 04, 2017 at 16:13

Ok so I am talking about the IRQ handlers for ADC, SPI, I2C USART etc..

I am expecting to see weak definitions of ADC_IRQHandler() function for example somewhere...but my startup_stm32.s file in startup directory does not know these functions...

I am using the System Workbench for STM32.

I only see the following:

.weak NMI_Handler

.thumb_set NMI_Handler,Default_Handler

.weak HardFault_Handler

.thumb_set HardFault_Handler,Default_Handler

.weak MemManage_Handler

.thumb_set MemManage_Handler,Default_Handler

.weak BusFault_Handler

.thumb_set BusFault_Handler,Default_Handler

.weak UsageFault_Handler

.thumb_set UsageFault_Handler,Default_Handler

.weak SVC_Handler

.thumb_set SVC_Handler,Default_Handler

.weak DebugMon_Handler

.thumb_set DebugMon_Handler,Default_Handler

.weak PendSV_Handler

.thumb_set PendSV_Handler,Default_Handler

.weak SysTick_Handler

.thumb_set SysTick_Handler,Default_Handler

Can someone help?

5 REPLIES 5
Posted on March 04, 2017 at 19:16

The body code is typically in stm32fxyz_it.c and the table with weak definitions is in startup_stm32fxyz.s, or the linker script. The weak linkage is sufficient for unused vectors, you're expected to put handler code in your own .C files.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on March 06, 2017 at 06:01

Ok first of all I am new to ST micro devices and the system workbench. However I am well familiar with Atmel microcontrollers and their ARM ranges. I am still struggling to find out more about these _IRQHandler functions...

I created a project in SystemWorkbench there is no stm32fxyz_it.c file I see the 'stm32f4xx_it.h' however under /inc directory.

Inside this header file there exists only the following function definitions:

void NMI_Handler(void);

void HardFault_Handler(void);

void MemManage_Handler(void);

void BusFault_Handler(void);

void UsageFault_Handler(void);

void SVC_Handler(void);

void DebugMon_Handler(void);

void PendSV_Handler(void);

void SysTick_Handler(void);

So where are the definitions (or even the weak ones) for example ADC_IRQHandler()?

As mentioned above they DO NOT exist in 'startup_stm32.s'. In this file also the 'g_pfnVectors' table shows as follows:

 g_pfnVectors:

.word _estack

.word Reset_Handler

.word NMI_Handler

.word HardFault_Handler

.word MemManage_Handler

.word BusFault_Handler

.word UsageFault_Handler

.word 0

.word 0

.word 0

.word 0

.word SVC_Handler

.word DebugMon_Handler

.word 0

.word PendSV_Handler

.word SysTick_Handler

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0

.word 0
Posted on March 06, 2017 at 14:29

You'll observe you didn't specify a part in your original post, STM32 covers hundreds of different parts. The body code is frequently placed in stm32f4xx_it.c, but can be anywhere in your compiled code.

It would appear that you are using a generic startup_stm32.s rather than a part specific startup_stm32f401xx.c type file, and your vector table only contains the system handlers common to Cortex-M3/M4 parts. Check why your chosen tool chain does this, I'm not using it.

STM32F4xx_DSP_StdPeriph_Lib_V1.8.0\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\SW4STM32\startup_stm32f427_437xx.s

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
nichtgedacht
Senior
Posted on March 06, 2017 at 20:13

Hi

In all my CubeMX projects generated for 'System Workbench for STM32'  the missing weak definitions can be found in

startup/startup_stm32xxxxx.s.

In Src/stm32l4xx_it.c and Inc/stm32l4xx_it.h only the used functions exists.

There must be something wrong with your setup.

How did you import the project to SW4STM32?

I use the generated directory as workspace, which contains the project folder. Then Import: General -> 'Existing Projects into Workspace'  and poimt to the generated Dir above project folder. That is the default if you click on browse.

Dieter

Posted on April 05, 2018 at 07:06

I have a similar problem. My project also has the generic startup file. When I searched for the startup file startup_stm32f103x8 in the Firmware folder, it had the startup for every other controller in the series, (stm32f103x6, xb, xc, xg) but not my x8.

I have downloaded the firmware just yesterday but it still doesn't have provisions for my controller. I am thinking of hitting the STM32F103C8 board so had on the wall that it breaks into 103 pieces.

Damn you ST and AC6!!

When you have been shipping the C8 chips for some 10 years, why not take 10 minutes to make its startup file and include in the Firmware???

0690X00000604YfQAI.jpg