Notes on Transplantation of uC/OS-II on C51

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.