Skip to main content
Arduino

Return to Answer

Commonmark migration
Source Link

This:

SP = (uint16_t)(&dummy)

is changing the stack pointer. Not what you want. You want to instead push the destination address to the stack. However, rather than simulating a function return, it should be simpler to perform an indirect jump:

asm volatile("ijmp" :: "z"(dummy));

Don't forget that your naked ISR has to save all the call-used registers, as well as SREG, r0 and r1, in its custom prologue. And restore them in its epilogue. Check the AVR calling conventions.

This:

SP = (uint16_t)(&dummy)

is changing the stack pointer. Not what you want. You want to instead push the destination address to the stack. However, rather than simulating a function return, it should be simpler to perform an indirect jump:

asm volatile("ijmp" :: "z"(dummy));

Don't forget that your naked ISR has to save all the call-used registers, as well as SREG, r0 and r1, in its custom prologue. And restore them in its epilogue. Check the AVR calling conventions.

This:

SP = (uint16_t)(&dummy)

is changing the stack pointer. Not what you want. You want to instead push the destination address to the stack. However, rather than simulating a function return, it should be simpler to perform an indirect jump:

asm volatile("ijmp" :: "z"(dummy));

Don't forget that your naked ISR has to save all the call-used registers, as well as SREG, r0 and r1, in its custom prologue. And restore them in its epilogue. Check the AVR calling conventions.

Source Link
Edgar Bonet
  • 45.1k
  • 4
  • 42
  • 81

This:

SP = (uint16_t)(&dummy)

is changing the stack pointer. Not what you want. You want to instead push the destination address to the stack. However, rather than simulating a function return, it should be simpler to perform an indirect jump:

asm volatile("ijmp" :: "z"(dummy));

Don't forget that your naked ISR has to save all the call-used registers, as well as SREG, r0 and r1, in its custom prologue. And restore them in its epilogue. Check the AVR calling conventions.

AltStyle によって変換されたページ (->オリジナル) /