Using software timers in μc/Os

Source: Internet
Author: User

In the process of trying to transplant μc/Os onto the ARM7 chip (LPC2138), it was found that OSTMR created with Ostmrcreate was never able to execute Callbackfunction,os version v2.85, and finally resolved.

A description of the function "Ostmrsignal ()" was found in the document "Ucos-ii-refman.pdf":

Ostmrsignal () is called either by a task or an ISR to indicate that it's time to update the timers. Typically, ostmrsignal () would is called by Ostimetickhook () at a multiple of the tick rate.

It indicates the need to call "ostmrsignal ()" To update the timer. So you probably know where the problem is, and here's an example from the documentation:

#if Os_tmr_en > 0static0; #endif void Ostimetickhook (void) {#if os_tmr_en > 0 ostmrtickctr+ +; if  (Ostmrtickctr >= (os_ticks_per_sec/0; Ostmrsignal ();} #endif }

So modify the hook function, add the above code, I am not quite sure where the new static local variables are more appropriate, so it is also placed in the hook function, this way:

/*********************************************************************************************************** TICK hook** description:this function is called every tick.** arguments:none** Note (s): 1) interrupts may or May is is ENABLED during this call.******************************************************** **************************************************/#if(Os_cpu_hooks_en > 0) && (os_time_tick_hook_en > 0)voidOstimetickhook (void){#ifOs_tmr_en > 0Staticint16u ostmrtickctr =0; #endif    #ifOs_tmr_en > 0ostmrtickctr++; if(Ostmrtickctr >= (os_ticks_per_sec/os_tmr_cfg_ticks_per_sec)) {ostmrtickctr=0;    Ostmrsignal (); }#endif}#endif

Finally in the Proteus inside verify pass.

Before the use of ΜC/OS-III software timer, directly with it, it seems that do not need to do so ah.

I feel the transplant operating system is too difficult for me, OK, not a transplant, just rewrite the BSP!

Using software timers in μc/Os

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.