I have read the article about the transplantation of UC on the C51 by Mr. Yang from julong. However, with the understanding of UC, it is found that the task function in the porting program of instructor Yang cannot pass parameters, so he tried to change it.
The running process of UC is as follows: 1. osinit () function initializes idle tasks. If there may be statistical tasks, of course, there are PCB and event idle lists (I think anyone who knows UC knows how to get started ); 2. ostaskcreate () function. In this function, you first call ostaskstkinit () to initialize the stack. When using this function, instructor Yang aims to make R7 = 0x07, the parameter passed through ppdata is not used, so the parameter cannot be passed. Why did I mention R7? Because the Keil compiler uses R7 to pass the first parameter ppdata
Just set * STK ++ = 0x07; // r7
Change to * STK ++ = (OS _stk *) ppdata; // R7. ppdata can be uploaded to the task function through R7.
In addition, R7 can only put 8 bits. Therefore, we recommend that you put taskdata in idata, for example, declare the variable int8u idata taskdata;
Task function: Void task (void idata * PD) reentrant; int8u c = * (int8u *) PD
You can use it.