7979#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\
8080 STM32F479xx */
8181
82- /*!< Uncomment the following line if you need to relocate your vector Table in
83- Internal SRAM. */
84- /* #define VECT_TAB_SRAM */
8582#ifndef VECT_TAB_OFFSET
86- #define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
87- This value must be a multiple of 0x200. */
83+ #define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
84+ This value must be a multiple of 0x200. */
85+ #else
86+ #define USER_VECT_TAB_ADDRESS
8887#endif
88+
89+ /* Note: Following vector table addresses must be defined in line with linker
90+ configuration. */
91+ /*!< Uncomment the following line if you need to relocate the vector table
92+ anywhere in Flash or Sram, else the vector table is kept at the automatic
93+ remap of boot address selected */
94+ /* #define USER_VECT_TAB_ADDRESS */
95+
96+ #if defined(USER_VECT_TAB_ADDRESS )
97+ /*!< Uncomment the following line if you need to relocate your vector Table
98+ in Sram else user remap will be done in Flash. */
99+ /* #define VECT_TAB_SRAM */
100+ #if defined(VECT_TAB_SRAM )
101+ #define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
102+ This value must be a multiple of 0x200. */
103+ #else
104+ #define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
105+ This value must be a multiple of 0x200. */
106+ #endif /* VECT_TAB_SRAM */
107+ #endif /* USER_VECT_TAB_ADDRESS */
89108/******************************************************************************/
90109
91110/**
@@ -170,12 +189,10 @@ void SystemInit(void)
170189 SystemInit_ExtMemCtl ();
171190#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
172191
173- /* Configure the Vector Table location add offset address ------------------*/
174- #ifdef VECT_TAB_SRAM
175- SCB -> VTOR = SRAM_BASE | VECT_TAB_OFFSET ; /* Vector Table Relocation in Internal SRAM */
176- #else
177- SCB -> VTOR = FLASH_BASE | VECT_TAB_OFFSET ; /* Vector Table Relocation in Internal FLASH */
178- #endif
192+ /* Configure the Vector Table location -------------------------------------*/
193+ #if defined(USER_VECT_TAB_ADDRESS )
194+ SCB -> VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET ; /* Vector Table Relocation in Internal SRAM */
195+ #endif /* USER_VECT_TAB_ADDRESS */
179196}
180197
181198/**
@@ -381,6 +398,7 @@ void SystemInit_ExtMemCtl(void)
381398
382399 /* PALL command */
383400 FMC_Bank5_6 -> SDCMR = 0x00000012 ;
401+ tmpreg = FMC_Bank5_6 -> SDSR & 0x00000020 ;
384402 timeout = 0xFFFF ;
385403 while ((tmpreg != 0 ) && (timeout -- > 0 ))
386404 {
@@ -389,6 +407,7 @@ void SystemInit_ExtMemCtl(void)
389407
390408 /* Auto refresh command */
391409 FMC_Bank5_6 -> SDCMR = 0x00000073 ;
410+ tmpreg = FMC_Bank5_6 -> SDSR & 0x00000020 ;
392411 timeout = 0xFFFF ;
393412 while ((tmpreg != 0 ) && (timeout -- > 0 ))
394413 {
@@ -397,6 +416,7 @@ void SystemInit_ExtMemCtl(void)
397416
398417 /* MRD register program */
399418 FMC_Bank5_6 -> SDCMR = 0x00046014 ;
419+ tmpreg = FMC_Bank5_6 -> SDSR & 0x00000020 ;
400420 timeout = 0xFFFF ;
401421 while ((tmpreg != 0 ) && (timeout -- > 0 ))
402422 {
@@ -586,6 +606,7 @@ void SystemInit_ExtMemCtl(void)
586606
587607 /* PALL command */
588608 FMC_Bank5_6 -> SDCMR = 0x00000012 ;
609+ tmpreg = FMC_Bank5_6 -> SDSR & 0x00000020 ;
589610 timeout = 0xFFFF ;
590611 while ((tmpreg != 0 ) && (timeout -- > 0 ))
591612 {
@@ -598,6 +619,7 @@ void SystemInit_ExtMemCtl(void)
598619#else
599620 FMC_Bank5_6 -> SDCMR = 0x00000073 ;
600621#endif /* STM32F446xx */
622+ tmpreg = FMC_Bank5_6 -> SDSR & 0x00000020 ;
601623 timeout = 0xFFFF ;
602624 while ((tmpreg != 0 ) && (timeout -- > 0 ))
603625 {
@@ -610,6 +632,7 @@ void SystemInit_ExtMemCtl(void)
610632#else
611633 FMC_Bank5_6 -> SDCMR = 0x00046014 ;
612634#endif /* STM32F446xx */
635+ tmpreg = FMC_Bank5_6 -> SDSR & 0x00000020 ;
613636 timeout = 0xFFFF ;
614637 while ((tmpreg != 0 ) && (timeout -- > 0 ))
615638 {
0 commit comments