请大伙帮看看程序是否有问题? 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_wait (K_TMO, 1, 0); os_delete_task (Initial_p); /* stop init task (no longer needed) */ }
/******************************************************************************/ /* Task 1 'SystemMan_p': command processor */ /******************************************************************************/ void SystemMan_P (void) _task_ SystemMan_p { char cByte2 = ' '; while (1) { Printf0 (cString2); PRLED = ~PRLED; os_wait (K_TMO, 1, 0); } } /******************************************************************************/ /* Task 2 'SystemMan_p' */ /******************************************************************************/ void Uart0Man_P (void) _task_ Uart0Man_p { while (1) { Printf0 (cString3); PGLED = ~PGLED; os_wait (K_TMO, 1, 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 = ~RADRLED; os_wait (K_TMO, 1, 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 = ~RADGLED; os_wait (K_TMO, 1, 0); } }
/******************************************************************************/ /* Task 5 'FlashMan_p': process key stroke from pedestrian push button */ /******************************************************************************/ void FlashMan_P (void) _task_ FlashMan_p {
while (1) { Printf0 (cString6); SRLED = ~SRLED ; os_wait (K_TMO, 1, 0); } }
/******************************************************************************/ /* Task 6 'StaDisplay_p': check if ESC (escape character) was entered */ /******************************************************************************/ void StaDisplay_P (void) _task_ StaDisplay_p { while (1) { Printf0 (cString7); SGLED = ~SGLED; os_wait (K_TMO, 1, 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 = ~BLT_BLED; os_wait (K_TMO, 1, 0); } }
配置如下: Define the register bank used for the timer interrupt. INT_REGBANK EQU 1 ; default is Registerbank 1 ; ; Define Hardware-Timer tick time in 8051 machine cycles. INT_CLOCK EQU 65535 ; default is 10000 cycles ; ; Define Round-Robin Timeout in Hardware-Timer ticks. TIMESHARING EQU 5 ; default is 5 Hardware-Timer ticks. ; ; 0 disables Round-Robin Task Switching ; ; Long User Interrupt Routines: set to 1 if your application contains ; user interrupt functions that may take longer than a hardware timer ; interval for execution. LONG_USR_INTR EQU 0 ; 0 user interrupts execute fast. ; ; 1 user interrupts take long execution times. ;
执行结果却只是: Command: 1 Command: 2 Command: 3 Command: 4 Command: 5 Command: 6 Command: 7 Command: 8 Command: 2 Command: 3 Command: 4 Command: 5
到底是不是时间片设置的问题,只有修改INT_CLOCK EQU时,打印结果会变。到底是什么缘故呢?请各位赐教!谢谢 |