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

NVIC does not tail-chain to PendSV ISR

I'm trying to implement context switching from handler mode to thread mode using PendSV. I set the PendSV pending bit inside an ISR with SCB->ICSR = SCB->ICSR | SCB_ICSR_PENDSVSET_Msk. After setting the PendSV pending bit, I can see that the PendSV exception is pending: SCB->ICSR = 0x10000813 (I think the ISRPREEMPT bit should be set as well but it's not).

NVIC should tail-chain to my PendSV handler before unstacking. Instead ISR unstacking occurs, a return to exception is executed, and a few thread-level instructions are executed, before the PendSV handler is called.

The SoftDevice is present but has not been enabled.

Any ideas on what might be causing this? Thanks.

Parents
  • Thanks, Aryan, for replicating the problem and responding here. I was wondering the same thing, if the debugger (I'm using GDB) is unable to monitor tail-chaining as it happens. I was thinking of setting a breakpoint in the PendSV handler, running to the breakpoint and comparing the stack to what I think it should be. Alternatively, I could try printing and comparing the value of the stack pointer (MSP) in both exception handlers. I'll let you know what I find.

Reply
  • Thanks, Aryan, for replicating the problem and responding here. I was wondering the same thing, if the debugger (I'm using GDB) is unable to monitor tail-chaining as it happens. I was thinking of setting a breakpoint in the PendSV handler, running to the breakpoint and comparing the stack to what I think it should be. Alternatively, I could try printing and comparing the value of the stack pointer (MSP) in both exception handlers. I'll let you know what I find.

Children
No Data
Related