Skip to content

Commit 8645971

Browse files
committed
Fix delayMicroseconds() to use 64bit period
fixes: #5000
1 parent 5502879 commit 8645971

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: cores/esp32/esp32-hal-misc.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ void delay(uint32_t ms)
160160

161161
void ARDUINO_ISR_ATTR delayMicroseconds(uint32_t us)
162162
{
163-
uint32_t m = micros();
163+
uint64_t m = (uint64_t)esp_timer_get_time();
164164
if(us){
165-
uint32_t e = (m + us);
165+
uint64_t e = (m + us);
166166
if(m > e){ //overflow
167-
while(micros() > e){
167+
while((uint64_t)esp_timer_get_time() > e){
168168
NOP();
169169
}
170170
}
171-
while(micros() < e){
171+
while((uint64_t)esp_timer_get_time() < e){
172172
NOP();
173173
}
174174
}

0 commit comments

Comments
 (0)