Skip to main content
nefarius2001-stm
Associate
November 21, 2013
Question

Problem using NVIC_SetVectorTable on StmF3Discovery

  • November 21, 2013
  • 2 replies
  • 767 views
Posted on November 22, 2013 at 00:44

Hi there,

I've got a problem here using NVIC_SetVectorTable().

I have attached my test programm, which is held very simple and does:

- Init Leds&UserButton

- make sure the ''new'' Vectortable is 0x200-aligned

- Copy the VectorTable from 0 to MyVectTable (0x20000200)

- // at the moment deactivated: change Systick-vector so I can see the new one is used

- Activate Systick to have an interrupt occuring

- When the UserButton is pressed, call NVIC_SetVectorTable(NVIC_VectTab_RAM,(int) &MyIsrTable);

And then the program counter ends up at 0x0 (but I had other weired effects when I slightly changed the code, e.g. PC at 0x20000200 or running wildly somewhere)

I guess I am missing a small but important detail. Can anyone see it?

Cheers
    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    November 22, 2013
    Posted on November 22, 2013 at 01:13

    >>NVIC_SetVectorTable(NVIC_VectTab_RAM,(int) &MyIsrTable);

    &MyIsrTable doesn't point a what you think it does.

    printf(''%p %p %p\n'',&MyIsrTable, MyIsrTable, &MyIsrTable[0]);

    I'd perhaps prefer

    NVIC_SetVectorTable((uint32_t)MyIsrTable, 0);

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    nefarius2001-stm
    Associate
    November 22, 2013
    Posted on November 22, 2013 at 16:22

    Perfect, thanks a lot!

    In the end, I'll probably just use

    SCB->VTOR = (uint32_t)MyIsrTable; // SetVectorTable

    Thanks!