This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cortex-M3: What happen to the stack pointer (sp) when setting VTOR?

The first entry of the vector-table is the initial value for the stack-pointer.

I'm asking me, will the stack-pointer be changed when VTOR was set?

Thanks for any help! :-)

  • Hello,

    I think VOTR will be initialized by a reset although the VTOR had been changed.

    Therefore, the sp initial value will always exist at address 0.

    Best regards,

    Yasuhiko Koumoto.

  • Hello,

    thanks for the answer, but I'm not sure if that was the thing what I want to know.

    Of course, after a reset of the CPU, the VTOR has it's default-value. With this, the stack pointer will be set also the the first value of the vector table (automatically).

    My question was: My app runs and after a while it sets the VTOR to another value than the initial value. The reason was the definiton of other interrupt-handlers.

    But what happened with the stack pointer? Will the SP be set (to the first entry of the NEW vector table) also (automatically)?

    If I understood you right, the SP will be set anyway (by resetting the CPU and when relocating the vectortable by setting VTOR by the application).

    Do I understand it correct?

    Thanks,

    jk

  • The Main stack pointer is loaded from the vector table by the processor at reset time only.

    Once out of reset, a subsequent change of the VTOR has no impact on the stack pointer, i.e. modifying the VTOR does not cause the stack pointer to be reloaded.

    Changing the VTOR causes any new exception to use the new value for the vector table base without requiring a reset.

    Best regards,

    Simon.

  • Hi Simon,

    thank you for clarification :-)

    jk