AnsweredAssumed Answered

PendSv not called or delayed call

Question asked by Legrand.Thomas.001 on Feb 28, 2014
Latest reply on Mar 3, 2014 by Legrand.Thomas.001

I have a strange issue using Atollic / JLink / STM32F2 working on a preemptive multitasking kernel.

I initialize my interrupts priorities like this:
NVIC_SetPriorityGrouping(6); // there is only 2 levels of preemption, one for system, the other for interrupts. This gives 8 levels of sub-priority for interrupts.
NVIC_SetPriority(SVCall_IRQn, 0x00); // set service call priority to highest priority
NVIC_SetPriority(SysTick_IRQn, 0x7F); // set systick interrupt to low but preemptive
NVIC_SetPriority(PendSV_IRQn, 0xFF); // set pend sv interrupt to low and not preemptive

And main function is called in thread mode (using PSP).

In the SVC Handler, I check if a task switch if needed, then pend a PendSv interrupt like this:

Debugging this with atollic, I have strange behavior, it seems the debugger skip interrupts when stepping (I have to place a breakpoint in the pendsv Handler to debug it), plus sometimes it is just not called at all.

For what reason the PendSv interrupt could be delayed or disabled?

I also tried to use the ITM_SendChar to send debug messages, but get hardfault trigger when using it ... except if I run it step by step using the debugger .......

Any idea ?

Best regards,
Thomas Legrand.