[En-Nut-Discussion] Timers running slow

Greg Wood greg.wood at shaw.ca
Fri Apr 28 05:56:16 CEST 2006


Hello everyone,

I'm having some trouble getting a simple timer to run on in my
application (a modified version of httpserv).  The timer does run, but
much slower than it should (approx 2-3 times too slow).  My timer
callback function is this:

void TimerCallback(HANDLE timer, void *arg)
{
    PORTB^=0x08;
}

this timer is started as follows:

timer1 = NutTimerStart(500, TimerCallback, NULL, 0);

Am I doing something totally stupid here?  I've also got another thread
running:

THREAD (blinky, arg)
{
 DDRB|=0x0F;
 char  i;
 for(;;)
 {
  for(i=0;i<blinks;i++)
   {
   PORTB|=0x01;
   NutSleep(125);
   PORTB&=~0x01;
   NutSleep(125);
   }
   NutSleep(1000);
 }
}

blinks is a global variable set by other functions.  The important part
here is that I have noticed that the time is off in this thread as well.
The nutsleeps take ~2-3x longer than they should.  What might be causing
these problems?

Greg Wood

-- 
Internal Virus Database is out-of-date.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.2.0/276 - Release Date:
07/03/2006
 




More information about the En-Nut-Discussion mailing list