I have previously used FreeRTOS successfully for a project targeting the SAM4E16E. I’m now doing a project on a SAM4S2A and having some trouble. I’m using Keil uVision V188.8.131.52.
I noticed that recent uVision project wizards had the ability to include FreeRTOS, so I did that when configuring the project, rather than using the manually-configured version as in the older project. It seems like there is some conflict in how the priority bits are defined.
I’m getting a failure in xPortStartScheduler, particularly the line:
configASSERT( ( portMAX_PRIGROUP_BITS - ulMaxPRIGROUPValue ) == configPRIO_BITS );
The version of port.c I’m using comes from:
I’m not sure this is the right version, but the values in the CM4 versions looked similar.
portMAX_PRIOGROUP_BITS is defined as 7
The version of FreeRTOSConfig.h I’m using was created under RTE\RTOS\FreeRTOSConfig.h and defines configPRIO_BITS like this:
#ifdef __NVIC_PRIO_BITS /* __NVIC_PRIO_BITS will be specified when CMSIS is being used. */ #define configPRIO_BITS __NVIC_PRIO_BITS #else /* 7 priority levels */ #define configPRIO_BITS 3 #endif
NVIC_PRIO_BITS comes from the pack: SAM4\DFP\1.6.1\Device\Include\Sam4S\sam4s2b.h where it is defined as 4.
So, it appears that maybe when parsing FreeRTOS.h, NVIC_PRIO_BITS is not in scope, and therefore we’re getting configPRIO_BITS equal to 3, and the runtime value of ulMaxPRIGROUPValue is 3, so it’s checking to see if 7 - 3 == 3.
I could do something to hack these generated files so NVIC_PRIO_BITS would be in scope when FreeRTOSConfig.h is parsed, but it seems like this should be something that the generated project code took care of. I’d like to do this the “right way” if possible. Any ideas where it went wrong?