[En-Nut-Discussion] AT91SAM7X-EK, UART messing up the NutSleep

Harald Kipp harald.kipp at egnite.de
Tue Jul 25 09:19:37 CEST 2006


Andras,

Looks like the correct fix to me too. Except, further down

         if (flags & TM_ONESHOT) {
             tn->tn_ticks = 0;
         } else {
             tn->tn_ticks = tn->tn_ticks_left;
         }

needs to be replaced by

         if (flags & TM_ONESHOT) {
             tn->tn_ticks = 0;
         } else {
             tn->tn_ticks = ticks;
         }

Otherwise periodic timer intervals would be too short.

Anyway, what puzzles me is the relatively large deviation in Jix'
test case.

Harald


At 16:22 24.07.2006 +0300, you wrote:
>Hi,
>
>As I can see the problem is that when you create a new timer for NutSleep()
>NutTimerProcessElapsed is not up to date with nut_ticks_resume holding a 
>value 3-4 timer tick smaller than actual time.
>That's why when doing first NutTimerProcessElapsed SleepTimer is 
>decremented with time elapsed from last processing, and not time from creation.
>Probably there are simple work around, but maybe the timer creating should 
>take care of the difference between nut_ticks_resume and NutGetTickCount().
>Should be nut_ticks_resume global for this?
>
>For example:
>
>NUTTIMERINFO * NutTimerCreate(u_long ticks, void (*callback) (HANDLE, void 
>*), void *arg, u_char flags)
>{
>    NUTTIMERINFO *tn;
>
>    tn = NutHeapAlloc(sizeof(NUTTIMERINFO));
>    if (tn) {
>        tn->tn_ticks_left = ticks+NutGetTickCount()-nut_ticks_resume;




More information about the En-Nut-Discussion mailing list