Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12690 Discussions

Question:NIOSII IDE, uCOSII, OSTimeTickHook

Altera_Forum
Honored Contributor II
1,362 Views

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.
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
534 Views

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.

0 Kudos
Altera_Forum
Honored Contributor II
534 Views

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
0 Kudos
Altera_Forum
Honored Contributor II
534 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
534 Views

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

0 Kudos
Reply