peter_mcc wrote on Thursday, August 08, 2013:
I am so disappointed. I just 30mins typing up this yesterday and SourceForge “had an error” when I tried to post it - so it’s all gone I should have learnt by now to copy things to the clipboard before submitting…
I’m trying to work out if there is a problem with my understanding or with the IAR Cortex M3 port.c file.
I’ve just upgraded to FreeRTOS 7.5.0 and enabled the configASSERT() macro. It showed that I had a few problems.
I fixed the first one in vPortValidateInterruptPriority( ) by making sure that I called NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); before calling NVIC_Init(&NVIC_InitStructure);. If you dig deep into the STM32 Standard Peripheral library docs it does say to do this but I didn’t notice. If you don’t do this then NVIC_Init sets the interrupt priority to zero - causing configASSERT( ucCurrentPriority >= ucMaxSysCallPriority ); to fail.
But I got stuck on this one:
/* Priority grouping: The interrupt controller (NVIC) allows the bits
that define each interrupt's priority to be split between bits that
define the interrupt's pre-emption priority bits and bits that define
the interrupt's sub-priority. For simplicity all bits must be defined
to be pre-emption priority bits. The following assertion will fail if
this is not the case (if some bits represent a sub-priority).
If CMSIS libraries are being used then the correct setting can be
achieved by calling NVIC_SetPriorityGrouping( 0 ); before starting the
scheduler. */
configASSERT( ( portAIRCR_REG & portPRIORITY_GROUP_MASK ) == 0x0000 );
After I call NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); the priority bits in AIRCR are set to 3, not zero. To get things to work I had to change the assertion to
configASSERT( ( portAIRCR_REG & portPRIORITY_GROUP_MASK ) == [b]0x0300[/b] );
Is that a bug in the port.c file? It seems to work ok once I’ve changed it.
I find it still has hard-aborts in ISR’s but I’ll do some more reading before asking for help.
Peter
PS Some of the info is here to help someone else who comes across the same problem