1、首先,这个用法不好,如果使用了CMSIS-RTOS V2封装层,就不要再调用FreeRTOS的原生API了,比如vTaskDelay等,这种情况就建议不要使用封装层了。
2、然后这个问题可以调试排查下,调试状态先看这个任务创建后,在调试的memory空间看下stack空间都填充为对应值没
[C] 纯文本查看 复制代码 /*
* The value used to fill the stack of a task when the task is created. This
* is used purely for checking the high water mark for tasks.
*/
#define tskSTACK_FILL_BYTE ( 0xa5U )
然后调试进入这个任务的函数uxTaskGetStackHighWaterMark运行后,看看memory的变化,同时单步调试进入这个函数里面看看这个的判断
[C] 纯文本查看 复制代码 static configSTACK_DEPTH_TYPE prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte )
{
configSTACK_DEPTH_TYPE uxCount = 0U;
while( *pucStackByte == ( uint8_t ) tskSTACK_FILL_BYTE )
{
pucStackByte -= portSTACK_GROWTH;
uxCount++;
}
uxCount /= ( configSTACK_DEPTH_TYPE ) sizeof( StackType_t );
return uxCount;
} |