Skip to content

Commit 9f3f053

Browse files
committed
[L4] Update the system source file
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 4da1a5f commit 9f3f053

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

system/STM32L4xx/system_stm32l4xx.c

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,30 @@
108108
*/
109109

110110
/************************* Miscellaneous Configuration ************************/
111-
/*!< Uncomment the following line if you need to relocate your vector Table in
112-
Internal SRAM. */
113-
/* #define VECT_TAB_SRAM */
114111
#ifndef VECT_TAB_OFFSET
115-
#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
116-
This value must be a multiple of 0x200. */
112+
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
113+
This value must be a multiple of 0x200. */
114+
#else
115+
#define USER_VECT_TAB_ADDRESS
117116
#endif
117+
118+
/* Note: Following vector table addresses must be defined in line with linker
119+
configuration. */
120+
/*!< Define USER_VECT_TAB_ADDRESS if you need to relocate the vector table
121+
anywhere in Flash or Sram, else the vector table is kept at the automatic
122+
remap of boot address selected */
123+
#if defined(USER_VECT_TAB_ADDRESS)
124+
/*!< Define VECT_TAB_SRAM if you need to relocate your vector Table
125+
in Sram else user remap will be done in Flash. */
126+
#if defined(VECT_TAB_SRAM)
127+
#define VECT_TAB_BASE_ADDRESS SRAM1_BASE /*!< Vector Table base address field.
128+
This value must be a multiple of 0x200. */
129+
#else
130+
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
131+
This value must be a multiple of 0x200. */
132+
#endif /* VECT_TAB_SRAM */
133+
#endif /* USER_VECT_TAB_ADDRESS */
134+
118135
/******************************************************************************/
119136
/**
120137
* @}
@@ -169,10 +186,15 @@
169186

170187
void SystemInit(void)
171188
{
189+
#if defined(USER_VECT_TAB_ADDRESS)
190+
/* Configure the Vector Table location -------------------------------------*/
191+
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
192+
#endif
193+
172194
/* FPU settings ------------------------------------------------------------*/
173-
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
174-
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
175-
#endif
195+
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
196+
SCB->CPACR |= ((3UL << 20U)|(3UL << 22U)); /* set CP10 and CP11 Full Access */
197+
#endif
176198

177199
/* Reset the RCC clock configuration to the default reset state ------------*/
178200
/* Set MSION bit */
@@ -192,13 +214,6 @@ void SystemInit(void)
192214

193215
/* Disable all interrupts */
194216
RCC->CIER = 0x00000000U;
195-
196-
/* Configure the Vector Table location add offset address ------------------*/
197-
#ifdef VECT_TAB_SRAM
198-
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
199-
#else
200-
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
201-
#endif
202217
}
203218

204219
/**

0 commit comments

Comments
 (0)