Skip to content

Commit 8b1ac02

Browse files
bscott-zebraadbridge
authored andcommitted
STM32F3: Remove dependence upon a specific flash vector table location
The STM32F3 cmsis_nvic code is currently checking for a specific flash address when determining if the vector table is in flash or RAM. By changing the test to instead see if the vector table base is NOT set to the RAM address, it simplifies the code, and removes the dependency on the flash vectors being located at a specific address. This becomes important when adding a custom boot loader, which requires that the flash vector table location in the mbed project be at a different address.
1 parent 96b6e44 commit 8b1ac02

File tree

5 files changed

+5
-10
lines changed

5 files changed

+5
-10
lines changed

targets/TARGET_STM/TARGET_STM32F3/TARGET_STM32F302x8/device/cmsis_nvic.c

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

3333
#define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Vectors positioned at start of RAM
34-
#define NVIC_FLASH_VECTOR_ADDRESS (0x08000000) // Initial vector position in flash
3534

3635
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
3736
uint32_t *vectors = (uint32_t *)SCB->VTOR;
3837
uint32_t i;
3938

4039
// Copy and switch to dynamic vectors if the first time called
41-
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
40+
if (SCB->VTOR != NVIC_RAM_VECTOR_ADDRESS) {
4241
uint32_t *old_vectors = vectors;
4342
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
4443
for (i=0; i<NVIC_NUM_VECTORS; i++) {

targets/TARGET_STM/TARGET_STM32F3/TARGET_STM32F303x8/device/cmsis_nvic.c

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

3333
#define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Vectors positioned at start of RAM
34-
#define NVIC_FLASH_VECTOR_ADDRESS (0x08000000) // Initial vector position in flash
3534

3635
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
3736
uint32_t *vectors = (uint32_t *)SCB->VTOR;
3837
uint32_t i;
3938

4039
// Copy and switch to dynamic vectors if the first time called
41-
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
40+
if (SCB->VTOR != NVIC_RAM_VECTOR_ADDRESS) {
4241
uint32_t *old_vectors = vectors;
4342
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
4443
for (i=0; i<NVIC_NUM_VECTORS; i++) {

targets/TARGET_STM/TARGET_STM32F3/TARGET_STM32F303xC/device/cmsis_nvic.c

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

3333
#define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Vectors positioned at start of RAM
34-
#define NVIC_FLASH_VECTOR_ADDRESS (0x08000000) // Initial vector position in flash
3534

3635
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
3736
uint32_t *vectors = (uint32_t *)SCB->VTOR;
3837
uint32_t i;
3938

4039
// Copy and switch to dynamic vectors if the first time called
41-
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
40+
if (SCB->VTOR != NVIC_RAM_VECTOR_ADDRESS) {
4241
uint32_t *old_vectors = vectors;
4342
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
4443
for (i=0; i<NVIC_NUM_VECTORS; i++) {

targets/TARGET_STM/TARGET_STM32F3/TARGET_STM32F303xE/device/cmsis_nvic.c

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

3333
#define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Vectors positioned at start of RAM
34-
#define NVIC_FLASH_VECTOR_ADDRESS (0x08000000) // Initial vector position in flash
3534

3635
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
3736
uint32_t *vectors = (uint32_t *)SCB->VTOR;
3837
uint32_t i;
3938

4039
// Copy and switch to dynamic vectors if the first time called
41-
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
40+
if (SCB->VTOR != NVIC_RAM_VECTOR_ADDRESS) {
4241
uint32_t *old_vectors = vectors;
4342
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
4443
for (i=0; i<NVIC_NUM_VECTORS; i++) {

targets/TARGET_STM/TARGET_STM32F3/TARGET_STM32F334x8/device/cmsis_nvic.c

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

3333
#define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Vectors positioned at start of RAM
34-
#define NVIC_FLASH_VECTOR_ADDRESS (0x08000000) // Initial vector position in flash
3534

3635
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
3736
uint32_t *vectors = (uint32_t *)SCB->VTOR;
3837
uint32_t i;
3938

4039
// Copy and switch to dynamic vectors if the first time called
41-
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
40+
if (SCB->VTOR != NVIC_RAM_VECTOR_ADDRESS) {
4241
uint32_t *old_vectors = vectors;
4342
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
4443
for (i=0; i<NVIC_NUM_VECTORS; i++) {

0 commit comments

Comments
 (0)