如题,UCOSII 移植到51单片机(STC89C52RC)上运行3个任务控制LED灯闪烁正常,我多添加一个任务其中修改了OS_CFG.H中的OS_MAX_TASKS的值由原来的OS_MAX_TASKS=5 改成OS_MAX_TASKS=6(或者7/8/9……)后4个任务都不能正常运行了,请问是什么原因!谢谢……
主函数代码如下:
把任务增加到4个就不能正常运行了
[mw_shl_code=c,true]#include"includes.h"
sbit LED0 = P1 ^ 0;
sbit LED2 = P1 ^ 2;
sbit LED5 = P1 ^ 5;
sbit LED7 = P1 ^ 7;
OS_STK Task1Stk[MaxStkSize]; //创建任务堆栈
OS_STK Task2Stk[MaxStkSize];
OS_STK Task3Stk[MaxStkSize];
//OS_STK Task4Stk[MaxStkSize];
void Task1(void* ddata) reentrant
{
ddata = ddata;
while (1)
{
LED0 = ~LED0;
OSTimeDly(25); //在11.0592M晶振下,需要约切换一次任务,OSTimeDly(1);最小切换任务时间时钟节拍10ms
}
}
void Task2(void* ddata) reentrant
{
ddata = ddata;
while (1)
{
LED7 = ~LED7;
OSTimeDly(50);
// SBUF='a';
// while(!TI)
// {
// OSTimeDly(50);
// }
// TI=0; /**/
//
}
}
void Task3(void*ddata ) reentrant
{
ddata = ddata;
while (1)
{
LED2 = ~LED2;
OSTimeDly(10);
}
}
// void Task4(void*ddata ) reentrant
// {
// ddata = ddata;
// while (1)
// {
// LED5 = ~LED5;
// OSTimeDly(100);
// }
// }
void main(void)
{
P1 = 0xff;
OSInit();
InitTimer0();
init_UART();
OS_ENTER_CRITICAL(); //进入临界区(无法被中断打断)
OSTaskCreate(Task1, (void *) 0, &Task1Stk[0], 1);
OSTaskCreate(Task2, (void *) 0, &Task2Stk[0], 2);
OSTaskCreate(Task3, (void *) 0, &Task3Stk[0], 3);
//OSTaskCreate(Task4, (void *) 0, &Task4Stk[0], 4);
OS_EXIT_CRITICAL(); //退出临界区(可以被中断打断)
OSStart();
}
[/mw_shl_code]
[mw_shl_code=c,true]//OS_CFG.H中的部分配置
#define MaxStkSize 32
#define OS_MAX_EVENTS 1 /* Max. number of event control blocks in your application ... */
/* ... MUST be > 0 */
#define OS_MAX_FLAGS 1 /* Max. number of Event Flag Groups in your application ... */
/* ... MUST be > 0 */
#define OS_MAX_MEM_PART 1 /* Max. number of memory partitions ... */
/* ... MUST be > 0 */
#define OS_MAX_QS 1 /* Max. number of queue control blocks in your application ... */
/* ... MUST be > 0 */
#define OS_MAX_TASKS 5 /* Max. number of tasks in your application ... */
/* ... MUST be >= 2 */
#define OS_LOWEST_PRIO 7 /* Defines the lowest priority that can be assigned ... */
/* ... MUST NEVER be higher than 63! */
#define OS_TASK_IDLE_STK_SIZE 32 /* Idle task stack size (# of OS_STK wide entries) */
#define OS_TASK_STAT_EN 0 /* Enable (1) or Disable(0) the statistics task */
#define OS_TASK_STAT_STK_SIZE 32 /* Statistics task stack size (# of OS_STK wide entries) */
#define OS_ARG_CHK_EN 0 /* Enable (1) or Disable (0) argument checking */
#define OS_CPU_HOOKS_EN 0 /* uC/OS-II hooks are found in the processor port files */
[/mw_shl_code]
|