Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
21 years ago

Question:NIOSII IDE, uCOSII, OSTimeTickHook

Since I want to extend uCOSII with a Timer library (from Labrosse's book "Embedded Systems Building Blocks"), I tick off the "Include code for OSTimeTickHook" in RTOS settings.

So far so good, the OS_TIME_TICK_HOOK_EN is set, and the OSTimeTickHook() in /components/altera_nios2/UCossii/src/os_cpu_c.c is called.

However, it seems for me as a bad location to put my code, since os_cpu_c.c seems to be overwritten at design compile time(?).

Also because whatever I need to put in the hook func is pretty application specific (a call to TmrSignalTmr() in this case).

Is there something I miss, a better way to use OSTimeTickHook and other "hook" functions? Could I include something in my app, for example, that overrides the OSTimeTickHook() in /components/altera_nios2/UCossii/src/os_cpu_c.c ?

Thank you.

4 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You must set OS_CPU_HOOKS_EN = 0, and then you must declare ALL the hook functions in another file. Copy the hook functions out of OS_CPU_C.C and then just change the time tick hook function.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks for tip, didn't get it to work though,

    OSTimeTick() in /components/micrium_uc_osii/ucosii/src/os_core.c will not do the call if OS_CPU_HOOKS_EN is 0, it seems:

    # if OS_TIME_TICK_HOOK_EN > 0# if OS_CPU_HOOKS_EN

    OSTimeTickHook(); /* Call user definable hook */# endif# endif
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Guess I can comment out that inner# if in os_core.c, since it is processor independent and won't be overwritten...

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You need to redefine OSTimeTickHook in your own code (as well, as the rest of the OSxxxHook functions)