HiResTimer Usage

Discussion to talk about software related topics only.
Post Reply
SeeCwriter
Posts: 624
Joined: Mon May 12, 2008 10:55 am

HiResTimer Usage

Post by SeeCwriter »

Using a NANO, I'm trying to use the interrupt feature of the HiResTimer and I haven't been able to get it to work.

Is there something wrong with my test code?

Code: Select all

HiResTimer *hrt;

void UserMain(void * pd) 
{
  BYTE counter=0;
  
  OSChangePrio(MAIN_PRIO);

  InitializeStack();
  EnableAutoUpdate();
  GetDHCPAddressIfNecessary();

  InitIO();
  
  while( true )
  {
    hrt->start();
    Pins[10] = 1;
    OSTimeDly(TICKS_PER_SECOND*2);
  }
}

void InitIO()
{
  Pins[10].function( PIN_10_GPIO );

  hrt = HiResTimer::getHiResTimer( 1 );
  hrt->init(0.1);  // 100ms timer.
  hrt->setInterruptFunction( tx_timer_isr );
}

void tx_timer_isr()
{
  hrt->stop();
  Pins[10] = 0;
}
I connect a scope pin 10 of the module and pin 10 goes high, but it never goes low, meaning the interrupt is never executed. In one of the
example programs the interrupt function was set by using an ampersand char in front of the function name
(i.e. setInterruptFunction( &tx_timer_isr ). While that seems wrong to me, it didn't work either.
What am I missing?
Post Reply