Skip to content

Commit 94dd3f9

Browse files
committed
Update system_clock.c for VECT_TAB_OFFSET changes in target definition
1 parent be03c0d commit 94dd3f9

File tree

1 file changed

+15
-5
lines changed
  • targets/TARGET_STM/TARGET_STM32F4/TARGET_MTB_MTS_DRAGONFLY

1 file changed

+15
-5
lines changed

targets/TARGET_STM/TARGET_STM32F4/TARGET_MTB_MTS_DRAGONFLY/system_clock.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@
4040
/*!< Uncomment the following line if you need to relocate your vector Table in
4141
Internal SRAM. */
4242
/* #define VECT_TAB_SRAM */
43-
#ifndef VECT_TAB_OFFSET
4443
#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
4544
This value must be a multiple of 0x200. */
46-
#endif
4745

4846

4947
/* Select the clock sources (other than HSI) to start with (0=OFF, 1=ON) */
@@ -92,11 +90,23 @@ void SystemInit(void)
9290
SystemInit_ExtMemCtl();
9391
#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
9492

95-
/* Configure the Vector Table location add offset address ------------------*/
93+
#if defined(__ICCARM__)
94+
#pragma section=".intvec"
95+
#define FLASH_VTOR_BASE ((uint32_t)__section_begin(".intvec"))
96+
#elif defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
97+
extern uint32_t Load$$LR$$LR_IROM1$$Base[];
98+
#define FLASH_VTOR_BASE ((uint32_t)Load$$LR$$LR_IROM1$$Base)
99+
#elif defined(__GNUC__)
100+
extern uint32_t g_pfnVectors[];
101+
#define FLASH_VTOR_BASE ((uint32_t)g_pfnVectors)
102+
#else
103+
#error "Flash vector address not set for this toolchain"
104+
#endif
105+
96106
#ifdef VECT_TAB_SRAM
97-
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
107+
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */
98108
#else
99-
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
109+
SCB->VTOR = FLASH_VTOR_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */
100110
#endif
101111

102112
}

0 commit comments

Comments
 (0)