As the first task when the Schedular started should be loading the stack with the format the same as defined in the function *pxPortInitialiseStack(), I should expected that the pxCurrentTCB is pointing to the tcb of the task I created. and the first byte pointer stored inside the pxCurrentTCB, should be the top stack address of the task stack. This pointer should contants : 17(20),(0x11,0x12,0x13),LSB of PC , MSB of PC , 0xaa… right?
It seems to me that the pxCurrentTCB is not pointing to the TCB of the task I created (when schedular first started), any idea for such … happend… I believe that Cygnal 8051’s context switching is basically the same as the other 8051s right?
Sorry for so many questions and trouble all a lot.
I have tried to enforce the pxCurrentTCB to point to the first task, it would run the task for 1 tick ( I guess).
From the tasks.c , I found that the PC never loops the following code:
if( usCurrentNumberOfTasks == 1 )
{
/* As this is the first task it must also be the current task. */
pxCurrentTCB = ( volatile tskTCB * volatile ) pxNewTCB;
P1_5=0;
/* This is the first task to be created so do the preliminary
initialisation required. We will not recover if this call
fails, but we will report the failure. */
sReturn = prvInitialiseTaskLists();
Just have a trial, with no object files built with the main.c by SDCC with the same flags, the main.c will works fine(static variable initialization) .It seems that the linker is not working correctly with the makefile…
when the main.c links with the object files(rel), all static variables initialization failed.
I had solved the problem by reinitialize all the static variable before creating first task.
0C:4FE3 Fmain$__xinit_sLatchedError$0$0
0C:4FE5 F______Source_tasks$__xinit_pxCurrentTCB$0$0
0C:4FE8 F______Source_tasks$__xinit_sUsingPreemption$0$0
0C:4FEA F______Source_tasks$__xinit_usCurrentNumberOfTasks$0$0
0C:4FEC F______Source_tasks$__xinit_xTickCount$0$0
0C:4FEE F______Source_tasks$__xinit_ucTopUsedPriority$0$0
0C:4FEF F______Source_tasks$__xinit_ucTopReadyPriority$0$0
0C:4FF0 F______Source_tasks$__xinit_cSchedulerRunning$0$0
0C:4FF1 F______Source_tasks$__xinit_ucSchedulerSuspended$0$0
0C:4FF2 F______Source_tasks$__xinit_ucMissedTicks$0$0
0C:4FF3 F______Source_portable_MemMang_heap_1$__xinit_usNextFreeByte$0$0
0C:4FF5 F___Common_Minimal_integer$__xinit_cTaskCheck$0$0
0C:4FF6 F___Common_Minimal_PollQ$__xinit_cPollingConsumerCount$0$0
0C:4FF7 F___Common_Minimal_PollQ$__xinit_cPollingProducerCount$0$0
And reduced the size of the following #define portMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 100 - ( unsigned portSHORT ) portSTACK_START )
The RTOS is working fine on my Atmel 89C51SND1 @ 16Mhz X2 mode(32Mhz) @ 1000Hz timer tick running for 12task + 1 idle task
Dunno why have such to happen, but anyway thanks to all~