Struggling with a very simple timer setup using the OSTimeTickHook() hook to bump a timer. unfortunately, Timer does not budge.
Here’s the code:
#class auto
#define OS_CPU_HOOKS_EN 1
#use UCOS2.LIB
unsigned count = 0 ;
unsigned temp_count = 0 ;
unsigned last_count = 0 ;
unsigned delta_count = 0 ;
void OSTimeTickHook( void ) ;
void main( void ) ;
//-----------------------------------------------------------------------------
// Main line.
//-----------------------------------------------------------------------------
void main()
{
OSInit();
OSTaskCreate( OSTimeTickHook, NULL, 512, 0 ) ;
while ( 1 ) {
costate {
temp_count = count ;
delta_count = temp_count - last_count;
printf( "Count = %u Last = %u Delta= %u
", temp_count, last_count, delta_count) ;
last_count = temp_count ;
waitfor(DelayMs(100));
} // costate
} // while
} // main
#asm
OSTimeTickHook::
ld hl, (count)
inc hl ; increment counter
ld (count), hl
ret
#endasm