From b95189a1a2caf3cd53c0e30f06752131bf878813 Mon Sep 17 00:00:00 2001 From: Rob Meades Date: Tue, 13 Jun 2017 13:00:31 +0100 Subject: [PATCH] Initialise RAM interrupt vector tables in SystemInit() as this is otherwise not done until *after* a call has already been made to NVIC_SetVector() in HAL_InitTick(). --- .../TARGET_UBLOX_C030/system_stm32f4xx.c | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/TARGET_UBLOX_C030/system_stm32f4xx.c b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/TARGET_UBLOX_C030/system_stm32f4xx.c index 970cb2dd8e1..96af67883c7 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/TARGET_UBLOX_C030/system_stm32f4xx.c +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/TARGET_UBLOX_C030/system_stm32f4xx.c @@ -78,6 +78,7 @@ */ +#include "ublox_low_level_api.h" #include "stm32f4xx.h" #include "hal_tick.h" @@ -122,9 +123,7 @@ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ -/* #define VECT_TAB_SRAM */ -#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ +#define VECT_TAB_SRAM /******************************************************************************/ /** @@ -215,10 +214,16 @@ void SystemInit(void) #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ /* Configure the Vector Table location add offset address ------------------*/ + SCB->VTOR = FLASH_BASE; /* Vector Table Relocation in Internal FLASH */ + #ifdef VECT_TAB_SRAM - SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ -#else - SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ + int *vectors = (int *)SCB->VTOR; + int *old_vectors = vectors; + vectors = (int *)NVIC_RAM_VECTOR_ADDRESS; + for (int i = 0; i < NVIC_NUM_VECTORS; i++) { + vectors[i] = old_vectors[i]; + } + SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS; #endif /* Configure the Cube driver */ @@ -232,7 +237,10 @@ void SystemInit(void) /* Reset the timer to avoid issues after the RAM initialization */ TIM_MST_RESET_ON; - TIM_MST_RESET_OFF; + TIM_MST_RESET_OFF; + + // Initialise the board + ublox_board_init(); } /** @@ -309,7 +317,6 @@ void SystemCoreClockUpdate(void) SystemCoreClock = pllvco/pllp; break; default: - SystemCoreClock = HSI_VALUE; break; } /* Compute HCLK frequency --------------------------------------------------*/ @@ -877,4 +884,4 @@ void SetSysClock(void) /** * @} */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ \ No newline at end of file +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/