I just create two tasks: task0 and task1, and I put the time ticker in the task0. The debug tool I use is Wiggler plus H-JTAG. The original code from J.J.Labrosse’s Web----AN1138 puts the time ticker initializaing function in a startup task. I don’t kown if this difference cause the problem. The following is my
app.c, including main() funtion.
Thanks a lot!
Sorry for wasting your time 
/*
*/
#include “includes.h”
/*
*/
#define LED (1 << 24 )
#define TASK_STK_SIZE 128
#define TASK_START_PRIO 5
/*
*/
OS_STK TaskStk0[TASK_STK_SIZE]; //Define the Task0 stack
OS_STK TaskStk1[TASK_STK_SIZE]; //Define the Task1 stack
OS_STK AppStartTaskStk[TASK_STK_SIZE];
/*
*/
void Task0(void *pdata); //Task0
void Task1(void *pdata); //Task0
#if OS_VIEW_MODULE > 0
static void AppTerminalRx(INT8U rx_data);
#endif
/*
*/
void main (void)
{
INT8U err;
BSP_IntDisAll(); /* Disable all interrupts until we are ready to accept them */
OSInit(); /* Initialize “uC/OS-II, The Real-Time Kernel” */
OSTaskCreateExt (Task0,(void *)0, (OS_STK *)&TaskStk0[TASK_STK_SIZE - 1],
6,6,(OS_STK *)&TaskStk0[0],
TASK_STK_SIZE,
(void *)0,
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
OSTaskNameSet(6,“Task0”,&err);
OSTaskCreateExt (Task1,(void *)0, (OS_STK *)&TaskStk1[TASK_STK_SIZE - 1],
7,7,(OS_STK *)&TaskStk1[0],
TASK_STK_SIZE,
(void *)0,
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR );
OSTaskNameSet(7,“Task1”,&err);
OSStart(); /* Start multitasking (i.e. give control to uC/OS-II) */
}
/$PAGE/
/*
-
STARTUP TASK
-
Description : This is an example of a startup task. As mentioned in the book’s text, you MUST
-
initialize the ticker only once multitasking has started.
-
Arguments : p_arg is the argument passed to ‘AppStartTask()’ by ‘OSTaskCreate()’.
-
Notes : 1) The first line of code is used to prevent a compiler warning because ‘p_arg’ is not
-
used. The compiler should not generate any code for this statement.
-
- Interrupts are enabled once the task start because the I-bit of the CCR register was
-
set to 0 by ‘OSTaskCreate()’.
*/
//static void AppStartTask (void *p_arg)
//{
// (void)p_arg;
// BSP_Init(); /* Initialize BSP functions */
//#if OS_TASK_STAT_EN > 0
// OSStatInit(); /* Determine CPU capacity */
//#endif
//#if OS_VIEW_MODULE > 0
// OSView_Init(38400);
// OSView_TerminalRxSetCallback(AppTerminalRx);
// OSView_RxIntEn(); /* Enable Rx Interrupts */
//#endif
// LED_Off(0); /* Turn OFF all the LEDs */
//while (TRUE) { /* Task body, always written as an infinite loop. */
// OSTimeDly(1);
// OSTaskSuspend(OS_PRIO_SELF);
//}
//}
/$PAGE/
/*
*/
#if OS_VIEW_MODULE > 0
static void AppTerminalRx (INT8U rx_data)
{
}
#endif
void Task0 (void *pdata)
{
pdata = pdata;
BSP_Init();
while (1)
{
IO1CLR = 1 << 24;
OSTimeDly(20);
}
}
void Task1 (void *pdata)
{
pdata = pdata;
while (1)
{
IO1SET = 1 <<24;
OSTimeDly(100);
}
}