PendSv not called or delayed call
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-02-28 8:23 AM
Posted on February 28, 2014 at 17:23
Hello,
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:
SCB ->ICSR |= SCB_ICSR_PENDSVSET_Msk;
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.
#nvic
Labels:
- Labels:
-
Interrupt
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-02-28 9:30 AM
Posted on February 28, 2014 at 18:30
More info ...
After the SVC set the PENDSVSET bit and exits, the VECTPENDING shows 0xE, PRIMASK is 0, CONTROL is 3 (user mode), PENDSVSET is still set, VECTACTIVE is zero (no active interrupt). Even ISRPREEMPT shows 1 (used in debug to show next instruction should be an interrupt). But the PendSv Handler is not called ... I can continue debug, nothing changes, it should trigger the pendsv but doesn't .... what am I missing ? Thomas.Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-02-28 9:31 AM
Posted on February 28, 2014 at 18:31
More info ...
After the SVC set the PENDSVSET bit and exits, the VECTPENDING shows 0xE, PRIMASK is 0, CONTROL is 3 (user mode), PENDSVSET is still set, VECTACTIVE is zero (no active interrupt). Even ISRPREEMPT shows 1 (used in debug to show next instruction should be an interrupt). But the PendSv Handler is not called ... I can continue debug, nothing changes, it should trigger the pendsv but doesn't .... what am I missing ? Thomas.Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-02-28 3:28 PM
Posted on March 01, 2014 at 00:28
The STM32F2 series only has 4 levels for the NVIC. Cortex M can go up to 8 but this is vendor dependent. Try setting your NVIC priority group to 4 bits for the IRQ levels and skip the sub level preemption.
Jack PeacockOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-03-03 2:14 AM
Posted on March 03, 2014 at 11:14
Hello,
I need 2 levels of preemption (1 bit) and 8 levels of sub priority (3 bits). Is my priority grouping wrong, should be 1 (the function is not well described, I inferred the parameter from code and datasheet, but I'm perhaps wrong) ? The parameter of SetPriorityGrouping is the number of bits assigned to preemption levels ? Thomas.