MDK是个封闭的IDE,不支持别人的RTOS,这样使用uc/OS-II无法显示任务栈使用情况,相比IAR就成了一个很**肋的开发工具,但是你可以在程序里面自己添加任务栈检查程序,如下所述:
static void AppTaskStacks (void *p_arg)
{
CPU_INT08U i;
CPU_INT16U green1;
CPU_INT16U green2;
CPU_INT16U green3;
CPU_INT16U black;
CPU_INT16U stk_pct;
CPU_INT32U stk_sz;
CPU_INT32U stk_use;
CPU_INT32U stk_max;
OS_TCB *ptcb;
CPU_INT08U s[10];
green1 = AppFormatColor(0, 31, 0);
green2 = AppFormatColor(0, 17, 0);
green3 = AppFormatColor(0, 8, 0);
black = AppFormatColor(0, 0, 0);
LCD_DispStr(27, 0, "Stack Size Demo: ", green3);
LCD_DispStr(28, 0, "The stack size, current stack ", green2);
LCD_DispStr(29, 0, "use and max stack use are shown ", green2);
LCD_DispStr(30, 0, "for each task. ", green2);
ptcb = &OSTCBTbl[0];
i = 0;
while (DEF_TRUE) {
OSTimeDlyHMSM(0, 0, 0, 25);
if (ptcb != NULL) {
stk_sz = ptcb->OSTCBStkSize * sizeof (OS_STK);
stk_use = (CPU_INT32U)(ptcb->OSTCBStkBase) - (CPU_INT32U)(ptcb->OSTCBStkPtr);
stk_max = ptcb->OSTCBStkUsed;
if (stk_sz != 0) {
stk_pct = 100 * stk_use / stk_sz;
LCD_DispStr (32 + i * 2, 0, ptcb->OSTCBTaskName, black);
if (stk_sz / 5 < 256) {
LCD_DispHorBar(32 + i * 2 + 1, 3, stk_sz / 5, 200, green1);
}
if (stk_max / 5 < 256) {
LCD_DispHorBar(32 + i * 2 + 1, 3, stk_max / 5, stk_max / 5, green2);
}
if (stk_use / 5 < 256) {
LCD_DispHorBar(32 + i * 2 + 1, 3, stk_use / 5, stk_use / 5, green3);
}
AppFormatDec(s, stk_pct, 2);
s[2] = '%';
LCD_DispStr (32 + i * 2 + 1,(stk_sz / 40) + 1, s, black);
}
ptcb = ptcb->OSTCBPrev;
i++;
} else {
ptcb = &OSTCBTbl[0];
i = 0;
}
}
}