#define Main_Stack_Size 320
static uint32_t threadMainStack[Main_Stack_Size];
const osThreadAttr_t threadAttr_threadmain = {
.name=
"Attr_Main", //Human readable Name for debugger
.attr_bits=
osThreadDetached,//Attribute_bits,
// NULL,//Control_Block_Memory,
// 0,//Control_Block_Size,
.stack_mem=
threadMainStack,//Stack_Memory,
.stack_size=
Main_Stack_Size*4,//Stack_Size,
.priority=
osPriorityNormal,//Priority,
// 0,//TrustZone_ID,
// 0//reserved
};
int main(void)
{
//...
tid_main = osThreadNew((osThreadFunc_t)task_main,NULL,&threadAttr_threadmain);
}
如代码所示,如果指定task_main堆栈位置threadMainStack[],则任务启动不了. 优化到O3则又可以了。怀疑是堆栈哪里不够,但启用了OS_STACK_CHECK, 不知道为什么没出现os_err, 直接不启动也不知道哪里的问题。
看了下网上的资料,发现不指定堆栈位置(os分配位置),仅指定大小则可以正常启动,不移动要O3优化。
#define Main_Stack_Size 320
//static uint32_t threadMa