Pages: [1]   Go Down
Author Topic: delay() issue - where to best report Due bugs?  (Read 525 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Shannon Member
****
Karma: 215
Posts: 12521
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Has anyone noticed the glaring bug in Due delay() function?
Code:
void delay( uint32_t ms )
{
    uint32_t end = GetTickCount() + ms;
    while (GetTickCount() < end)
    yield();
}
[ Namely failure to deal with wrap-around ]

Suggested fix:
Code:
void delay (uint32_t ms)
{
  if (ms == 0)
    return ;
  uint32_t start = GetTickCount () ;
  do { yield () ; } while (GetTickCount() - start < ms) ;
}
Logged

[ I won't respond to messages, use the forum please ]

Nashville Tennessee, USA
Offline Offline
Sr. Member
****
Karma: 15
Posts: 367
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Shannon Member
****
Karma: 215
Posts: 12521
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

[ I won't respond to messages, use the forum please ]

Pages: [1]   Go Up
Jump to: