Skip to content

Commit ebceb0b

Browse files
committed
[G4] Update the system source file
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent c8bf6e8 commit ebceb0b

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

system/STM32G4xx/system_stm32g4xx.c

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,31 @@
9595
*/
9696

9797
/************************* Miscellaneous Configuration ************************/
98-
/*!< Uncomment the following line if you need to relocate your vector Table in
99-
Internal SRAM. */
100-
/* #define VECT_TAB_SRAM */
10198
#ifndef VECT_TAB_OFFSET
102-
#define VECT_TAB_OFFSET 0x00UL /*!< Vector Table base offset field.
103-
This value must be a multiple of 0x200. */
99+
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
100+
This value must be a multiple of 0x200. */
101+
#else
102+
#define USER_VECT_TAB_ADDRESS
104103
#endif
104+
105+
/* Note: Following vector table addresses must be defined in line with linker
106+
configuration. */
107+
/*!< Uncomment the following line if you need to relocate the vector table
108+
anywhere in Flash or Sram, else the vector table is kept at the automatic
109+
remap of boot address selected */
110+
111+
#if defined(USER_VECT_TAB_ADDRESS)
112+
/*!< Uncomment the following line if you need to relocate your vector Table
113+
in Sram else user remap will be done in Flash. */
114+
/* #define VECT_TAB_SRAM */
115+
#if defined(VECT_TAB_SRAM)
116+
#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
117+
This value must be a multiple of 0x200. */
118+
#else
119+
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
120+
This value must be a multiple of 0x200. */
121+
#endif /* VECT_TAB_SRAM */
122+
#endif /* USER_VECT_TAB_ADDRESS */
105123
/******************************************************************************/
106124
/**
107125
* @}
@@ -161,11 +179,9 @@ void SystemInit(void)
161179
#endif
162180

163181
/* Configure the Vector Table location add offset address ------------------*/
164-
#ifdef VECT_TAB_SRAM
165-
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
166-
#else
167-
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
168-
#endif
182+
#if defined(USER_VECT_TAB_ADDRESS)
183+
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
184+
#endif /* USER_VECT_TAB_ADDRESS */
169185
}
170186

171187
/**

0 commit comments

Comments
 (0)