We explained earlier that when the system starts, the Systeminit function is called first to initialize the clock system, and the Systeminit also completes the Interrupt vector table settings. We can open the Systeminit function to see that there are several lines of code at the end of the function body:
#ifdef vect_tab_sram
scb- >vtor = Sram_base | Vect_tab_offset;
/* Vector Table relocation in Internal SRAM. */
#else
Cb->vtor = Flash_base | Vect_tab_offset;
/* Vector table relocation in Internal FLASH. */
#endif
From the code it is understandable that vtor registers hold the starting address of the interrupt vector table. The default condition Vect_tab_sram is undefined, so do scb->vtor = Flash_base | Vect_tab_offset; For the Flash app, we set the flash_base+ offset to 0x10000, so we can add the following code at the beginning of the main function of the Flash app to reset the start address of the interrupt vector table:
Scb->vtor = Flash_base | 0x10000
If APP2 can be set to Scb->vtor = Flash_base | 0x20000;
If APP3 can be set to Scb->vtor = Flash_base | 0x30000;
This completes the setting of the Interrupt vector table offset.
#define vect_tab_offset 0xc000
This is the address that is actually offset from the 0x8000000.