Skip to content

Commit cb1c4a5

Browse files
committed
[NANO130] Fix optimization error with NVIC_SetVector/NVIC_GetVector on ARMC6
On ARMC6 with optimization level "-Os", the two functions NVIC_SetVector/NVIC_GetVector will be optimized out. Add "volatile" qualifier to suppress it.
1 parent b21c278 commit cb1c4a5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

targets/TARGET_NUVOTON/TARGET_NANO100/device/cmsis_nvic.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
#include "cmsis_nvic.h"
1717
#include "platform/mbed_error.h"
1818

19+
/* Fix optimization error with NVIC_SetVector/NVIC_GetVector on ARMC6
20+
*
21+
* On ARMC6 with optimization level "-Os", the two functions NVIC_SetVector/
22+
* NVIC_GetVector will be optimized out. Add "volatile" qualifier to suppress
23+
* it.
24+
*/
25+
1926
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector)
2027
{
2128
// NOTE: On NANO130, relocating vector table is not supported due to just 16KB small SRAM.
@@ -28,7 +35,7 @@ void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector)
2835

2936
uint32_t NVIC_GetVector(IRQn_Type IRQn)
3037
{
31-
uint32_t *vectors = (uint32_t*) NVIC_FLASH_VECTOR_ADDRESS;
38+
volatile uint32_t *vectors = (volatile uint32_t *) NVIC_FLASH_VECTOR_ADDRESS;
3239

3340
// Return the vector
3441
return vectors[IRQn + 16];

0 commit comments

Comments
 (0)