Skip to content

Commit 2e7b645

Browse files
committed
[sam] Fixed wrap-around bug in delay() (Mark Tillotson)
Fixes #1736
1 parent e2b15c8 commit 2e7b645

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

build/shared/revisions.txt

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ ARDUINO 1.5.6 BETA
88
* TFT: warning messages in PImage class and strings inside examples now stored in flash to save RAM.
99
* Ethernet: added operator == for EthernetClient class (Norbert Truchsess)
1010

11+
[core]
12+
* sam: Fixed wrap-around bug in delay() (Mark Tillotson)
13+
1114
ARDUINO 1.5.5 BETA 2013.11.28
1215

1316
NOTICE:

hardware/arduino/sam/cores/arduino/wiring.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern "C" {
2525
uint32_t millis( void )
2626
{
2727
// todo: ensure no interrupts
28-
return GetTickCount() ;
28+
return GetTickCount() ;
2929
}
3030

3131
// Interrupt-compatible version of micros
@@ -74,9 +74,12 @@ uint32_t micros( void )
7474

7575
void delay( uint32_t ms )
7676
{
77-
uint32_t end = GetTickCount() + ms;
78-
while (GetTickCount() < end)
79-
yield();
77+
if (ms == 0)
78+
return;
79+
uint32_t start = GetTickCount();
80+
do {
81+
yield();
82+
} while (GetTickCount() - start < ms);
8083
}
8184

8285
#if defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */

0 commit comments

Comments
 (0)