ke7c2mi
ke7c2mi
DIIDevHeads IoT Integration Server
Created by Sterling on 9/11/2024 in #firmware-and-baremetal
How to Manually Program an Interrupt Service Routine (ISR) for STM32F4 MCU Without Using Libraries?
But how do we define that table? Well we can see how ST do it here: https://github.com/STMicroelectronics/cmsis_device_f4/blob/master/Source/Templates/arm/startup_stm32f401xc.s
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size

__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
....
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size

__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
....
This is startup code, we see the table of vectors being declared at line 60, but that's only half the story, we should also look at the linker file: https://github.com/STMicroelectronics/STM32CubeF4/blob/master/Projects/STM32446E-Nucleo/Templates/STM32CubeIDE/STM32F446RETX_FLASH.ld This is where the table actually gets placed at a specific location:
/* The startup code into "ROM" Rom type memory */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >ROM
/* The startup code into "ROM" Rom type memory */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >ROM
In English - put the symbol ".isr_vector" at the start of the ROM section - which is flash - which is where our table should be on startup ... we're still not done yet...
9 replies