[En-Nut-Discussion] timer problem
PragmaLab
info at pragmalab.nl
Tue May 13 10:50:04 CEST 2008
Hello Erik,
sorry for the delay, but I just got back to work after a week off.
Yes, we more or less worked around the bug in the same way you did. Like
you, I did not want to modify the NutOS timercode since I thought Harald
would sooner or later dive into the matter. We created the workaround just
by creating a local timer-structure that is updated by checking the elapsed
number of miliseconds, but we don't use a callback function.
This workaround is far less accurate then yours since we don't rely on the
OS that updates the elapsed milisecs and then calls the callback function.
But in our case the timer in question is just a time-out timer for the menu,
so 1 second more or less is OK for us.
#if (NUTOS_VERSION >= 421)
if (KeyToTimer.bActive)
{
// correct for elapsed nrof ticks since last call
ulTicks = NutGetTickCount();
ulTicksNew=ulTicks-KeyToTimer.ulTicksResume; //
elapsed ticks since last call
if (KeyToTimer.ulTicksLeft>ulTicksNew)
{
KeyToTimer.ulTicksLeft -= ulTicksNew; //
update running timer
KeyToTimer.ulTicksResume = ulTicks; // take
snapshot
}
else
{
MenuHandler(KEY_TIMEOUT); // timer
elapsed, now process....
}
}
#endif
As you can see, we handle the timeradministration completely in the
synchronous part (thread), while you use a callback function.
Regards,
Rob
> Hi.
> I experienced the exact same problem as you and did wrote my
> own administration.
>
> And it looks like its working, but perhaps you solved it in a
> much smarter way?
>
More information about the En-Nut-Discussion
mailing list