This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NVIC table

Hi,

could you please tell where can I find a table showing all the NVIC interrupt vectors?

I searched in the nRF52840 datasheet but I did not find something relevant

Thank you

Parents
  • To give you the short answer first: download the nRF52 SDK and look at the file modules/nrfx/mdk/nrf52840.h. It defines an enum called IRQn_Type which shows you all the vector numbers.

    Note that by ARM design conventions, the first 16 slots in the vector table are reserved for CPU-specific things. The vector table is at address 0x0 in the flash. The first two 32-bit words there define the initial stack pointer and reset vector, followed by 14 other CPU-specific vectors. The IRQ numbers for vendor-defined peripheral devices therefore start at the 16th entry in the table and go up from there.

    So for a given IRQ number, you can calculate the vector table slot address as follows:

    slotaddr = (IRQ number * 4) + (16 * 4)

    Where 4 is the size of a vector entry (4 bytes) and 16 is the number of slots reserved for the ARM core stuff described above.

    To give you a bit of a longer answer, the nRF52840 product specification does actually tell you the vector offsets, but in a left-handed sort of way. (I refer to this as the Minimum Information Game.)

    Look at the Peripherals section in the manual. Choose a given peripheral, for example the I2S controller (section 6.11). Now look at the Registers section (6.11.10). The first thing it tells you is the base address of the I2S register bank, which is 0x40025000.

    It turns out that the register bank offset for a peripheral is directly associated with the peripheral's NVIC interrupt. In this case, it's the value 0x25. This is 37 in decimal, and if you look at the IRQn_Type table, you'll see that I2S_IRQn is indeed 37.

    As a shortcut, you can also look at the Instantiation table in section 4.2.4. The "ID" column in the table also happens to be the same as the IRQ number.

    Note that not every ARM SoC vendor uses the same convention.

    Unfortunately I don't think the manual comes right out and says this in the same words that I just did. Arguably it should.

    -Bill

  • Thank you for your reply. Very Helpful! Thank you.

    Could you please answer me one more question on IRQs that confuses me?

    In the pin_change_int example, of the peripherals folder,

    when an input pin state change occurs ,  the event is serviced with the in_pin_handler() routine

    where the LED is toggled.

    Where is the interrupt get serviced in the code? There is no interrupt_handler() routine.

    So if I get it right, the handler function serves the IRQ of the input pin if the IRQ is enabled or, in case the interrupt is disabled, the same handler routine performs the actions (toggle led) when the event for the input pin is triggered.

    I am a little confused

    Does the nRF52840 follow the same logic?  Because from the pin_change_int  example, I understand that both event and interrupt are serviced from the event handler routine...There is no service routine specifically for the external interrupt

    Thank you for your time and help

  • Where is the interrupt get serviced in the code? There is no interrupt_handler() routine.

    It's in nrfx_gpiote_irq_handler(). From the vector table, you have the GPIOTE_IRQHandler, and in nrfx_irqs_nrf52840.h, we have that 

    #define nrfx_gpiote_irq_handler GPIOTE_IRQHandler 

    and nrfx_gpiote_irq_handler() can be found in nrfx driver folder in nrfx_gpiote.c. See this link.

    The registred handler( in_pin_handler() in this case) is called at line 707 in the interrupt handler driver, see this link. 

    Placing a breakpoint in in_pin_handler(), the call-stack looks like this in SES:

Reply Children
No Data
Related