Skip to content

Commit aa6ad1c

Browse files
committed
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
1 parent 15e4409 commit aa6ad1c

File tree

1 file changed

+2
-2
lines changed
  • libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K22F

1 file changed

+2
-2
lines changed

libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K22F/cmsis_nvic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
#include "cmsis_nvic.h"
3232

3333
#define NVIC_RAM_VECTOR_ADDRESS (0x1FFF0000) // Vectors positioned at start of RAM
34-
#define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
34+
#define NVIC_FLASH_VECTOR_ADDRESS (__vector_table) // Initial vector position in flash
3535

3636
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
3737
uint32_t *vectors = (uint32_t*)SCB->VTOR;
3838
uint32_t i;
3939

4040
// Copy and switch to dynamic vectors if the first time called
41-
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
41+
if (SCB->VTOR < NVIC_RAM_VECTOR_ADDRESS) {
4242
uint32_t *old_vectors = vectors;
4343
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
4444
for (i=0; i<NVIC_NUM_VECTORS; i++) {

0 commit comments

Comments
 (0)