HiResTimer Usage
Posted: Thu Feb 06, 2020 12:54 pm
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?
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?
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;
}
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?