Go Down

Topic: delay() issue - where to best report Due bugs? (Read 628 times) previous topic - next topic

MarkT

Has anyone noticed the glaring bug in Due delay() function?
Code: [Select]

void delay( uint32_t ms )
{
    uint32_t end = GetTickCount() + ms;
    while (GetTickCount() < end)
    yield();
}

[ Namely failure to deal with wrap-around ]

Suggested fix:
Code: [Select]

void delay (uint32_t ms)
{
  if (ms == 0)
    return ;
  uint32_t start = GetTickCount () ;
  do { yield () ; } while (GetTickCount() - start < ms) ;
}
[ I won't respond to messages, use the forum please ]

noblepepper

I believe you will get a warm reception at https://github.com/arduino/Arduino/issues?page=1&state=open, make sure you check the open issues to avoid a duplicate bug report.

MarkT

Thanks - if they had simply copied the Wait() function from libsam's timetick.c and
added the call to yield() it would have been fine!
[ I won't respond to messages, use the forum please ]

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy