Skip to content

Commit

Permalink
Merge pull request #1273 from marcusbirkin/master
Browse files Browse the repository at this point in the history
KL46Z - Ensure the NVIC table gets copied to RAM even when it is not at 0x0000
  • Loading branch information
0xc0170 committed Aug 13, 2015
2 parents 163a66a + 061cb87 commit bd9a168
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
#include "cmsis_nvic.h"

#define NVIC_RAM_VECTOR_ADDRESS (0x1FFFE000) // 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<NVIC_NUM_VECTORS; i++) {
Expand Down

0 comments on commit bd9a168

Please sign in to comment.