8 years, 4 months ago.

Can someone explain NUM_VECTORS?

Hello,

can someone explain to me, what is the following #defines in file cmsis_nvic.h

#define NVIC_NUM_VECTORS     
#define NVIC_USER_IRQ_OFFSET 

And how can I configure them for my target? I am using Tiva C launchpad TM4C123, Also I want to know what are those defines and how can i determine their values according to any target

One more question, is that following line of code

vectors[IRQn + 16] = vector;

can be replaced by

vectors[IRQn + NVIC_USER_IRQ_OFFSET ] = vector;

The reason I am asking this question is because that I don't understand what 16 is meant to be!

1 Answer

8 years, 4 months ago.

NUM_VECTORS is the number of IRQ lines in the MCU. There are 16 vectors belonging to the ARM core itself (that is where the 16 and USER_IRQ_OFFSET come from), such as the HardFault handler, SysTick, etc. After that the ones belonging to the manufacturer come. Since they start numbering at 0, while in fact you first got the 16 belonging to the ARM core, you need o add 16 to it.

Accepted Answer

Hi Erik, Alright, I have changed NVIC_NUM_VECTORS to 154 (which is the number of interrupts for my target) The system doesn't jump to hard fault anymore, but for some reason, it still points to the original interrupt handler and not pointing to the assigned one.

What could be going wrong here?

posted by Mohamed Saleh 30 Jul 2016

Hard to say without access to your target. You are checking the new location, and not the old one in the flash memory? The VTOR pointer points to the SRAM location if you run it through a debugger?

posted by Erik - 30 Jul 2016

is the VTOR pointer points to the SRAM location, YES. I guess (just guessing, correct me if i am wrong) the problem now is with my linker file, I don't have experience writing linker file for ARM GCC compiler(just reused old linker file I had). I guess that the processor write over the pointed memory addresses

posted by Mohamed Saleh 30 Jul 2016