From aa6ad1c52447fae48e5ecd7349df4c13c5f78f30 Mon Sep 17 00:00:00 2001 From: al177 Date: Wed, 21 Oct 2015 10:17:43 -0500 Subject: [PATCH] Copy NVIC to RAM from anywhere in flash Copy the NVIC from any address below RAM, not just at 0x0. This is helpful when using a bootloader, which must have its own vector table at 0x0. Identical to ebcee71 for TARGET_KL46Z. fix commit id --- .../targets/cmsis/TARGET_Freescale/TARGET_K22F/cmsis_nvic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K22F/cmsis_nvic.c b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K22F/cmsis_nvic.c index fc13c884fc..89bd640f58 100644 --- a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K22F/cmsis_nvic.c +++ b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K22F/cmsis_nvic.c @@ -31,14 +31,14 @@ #include "cmsis_nvic.h" #define NVIC_RAM_VECTOR_ADDRESS (0x1FFF0000) // Vectors positioned at start of RAM -#define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash +#define NVIC_FLASH_VECTOR_ADDRESS (__vector_table) // Initial vector position in flash void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) { uint32_t *vectors = (uint32_t*)SCB->VTOR; uint32_t i; // Copy and switch to dynamic vectors if the first time called - if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) { + if (SCB->VTOR < NVIC_RAM_VECTOR_ADDRESS) { uint32_t *old_vectors = vectors; vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS; for (i=0; i