We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
code as following,and run on c8051f020.
unsigned char code cString1[]={"\nCommand: 1\0"}; unsigned char code cString2[]={"\nCommand: 2\0"}; unsigned char code cString3[]={"\nCommand: 3\0"}; unsigned char code cString4[]={"\nCommand: 4\0"}; unsigned char code cString5[]={"\nCommand: 5\0"}; unsigned char code cString6[]={"\nCommand: 6\0"}; unsigned char code cString7[]={"\nCommand: 7\0"}; unsigned char code cString8[]={"\nCommand: 8\0"}; /******************************************************************************/ /* Task 0 'Initial_p': Initialize */ /******************************************************************************/ void Initial_P (void) _task_ Initial_p { /* program execution starts here */ unsigned int iCount = 0; Initial(); C8051ConfigBaud (96,0); /* initialize the serial interface */ C8051ConfigBaud (192,1); Printf0 (cString1); os_create_task (SystemMan_p); /* start clock task */ os_create_task (Uart0Man_p); /* start command task */ os_create_task (Uart1Man_p); /* start lights task */ os_create_task (RecvData_p); /* start keyread task */ os_create_task (FlashMan_p); os_create_task (StaDisplay_p); os_create_task (TimeMan_p); os_delete_task (Initial_p); /* stop init task (no longer needed) */ } /******************************************************************************/ /* Task 1 'SystemMan_p': command processor */ /******************************************************************************/ void SystemMan_P (void) _task_ SystemMan_p { while (1) { Printf0 (cString2); PRLED = 1; PRLED = 0; os_wait (K_TMO, 2, 0); } } /******************************************************************************/ /* Task 2 'SystemMan_p' */ /******************************************************************************/ void Uart0Man_P (void) _task_ Uart0Man_p { while (1) { Printf0 (cString3); PGLED = 1; PGLED = 0; os_wait (K_TMO, 2, 0); } } /******************************************************************************/ /* Task 3 'Uart1Man_p': runs if current time is outside start & end time */ /******************************************************************************/ void Uart1Man_P (void) _task_ Uart1Man_p { while (1) { Printf0 (cString4); RADRLED = 1; RADRLED = 0; os_wait (K_TMO, 2, 0); } } /******************************************************************************/ /* Task 4 'RecvData_p': executes if current time is between start & end time */ /******************************************************************************/ void RecvData_P (void) _task_ RecvData_p { while (1) { Printf0 (cString5); RADGLED = 1; RADGLED = 0; os_wait (K_TMO, 2, 0); } } /******************************************************************************/ /* Task 5 'FlashMan_p': process key stroke from pedestrian push button */ /******************************************************************************/ void FlashMan_P (void) _task_ FlashMan_p { while (1) { Printf0 (cString6); SRLED = 1 ; SRLED =0 ; os_wait (K_TMO, 2, 0); } } /******************************************************************************/ /* Task 6 'StaDisplay_p': check if ESC (escape character) was entered */ /******************************************************************************/ void StaDisplay_P (void) _task_ StaDisplay_p { while (1) { Printf0 (cString7); SGLED = 1; SGLED = 0; os_wait (K_TMO, 2, 0); } } /******************************************************************************/ /* Task 7 'TimeMan_p': check if ESC (escape character) was entered */ /******************************************************************************/ void TimeMan_P (void) _task_ TimeMan_p { while (1) { Printf0 (cString8); BLT_BLED = 1; BLT_BLED = 0; os_wait (K_TMO, 2, 0); } }
why the result only print: Command: 1 Command: 2 Command: 3 Command: 4 Command: 5 Command: 6 Command: 7 Command: 8 Command: 2 Command: 3 Command: 4
Nantian,
I've not used RTX-51 Tiny before, but something in your code looks suspicious. Namely:
os_delete_task (Initial_p); /* stop init task (no longer needed) */
It seems that the ONLY task that prints cString1 is "Initial_p" and you delete that task after its first execution. So, it's doing what I would expect: Executing the first time, printing its result, and then round-robining through the remaining tasks.