Skip to content

Commit e766292

Browse files
committed
🩹 Fix delay µs > 32767
Fixes #27753
1 parent 9c9ed69 commit e766292

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Marlin/src/HAL/shared/Delay.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void calibrate_delay_loop();
100100

101101
// For delay in microseconds, no smart delay selection is required, directly call the delay function
102102
// Teensy compiler is too old and does not accept smart delay compile-time / run-time selection correctly
103-
#define DELAY_US(x) DelayCycleFnc((x) * ((F_CPU) / 1000000UL))
103+
#define DELAY_US(x) DelayCycleFnc((unsigned long)(x) * ((F_CPU) / 1000000UL))
104104

105105
#elif defined(__AVR__)
106106
FORCE_INLINE static void __delay_up_to_3c(uint8_t cycles) {
@@ -164,7 +164,7 @@ void calibrate_delay_loop();
164164
}
165165

166166
// Delay in microseconds
167-
#define DELAY_US(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL))
167+
#define DELAY_US(x) DELAY_CYCLES((unsigned long)(x) * ((F_CPU) / 1000000UL))
168168

169169
#define DELAY_CYCLES_VAR DELAY_CYCLES
170170

@@ -173,7 +173,7 @@ void calibrate_delay_loop();
173173
// DELAY_CYCLES specified inside platform
174174

175175
// Delay in microseconds
176-
#define DELAY_US(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL))
176+
#define DELAY_US(x) DELAY_CYCLES((unsigned long)(x) * ((F_CPU) / 1000000UL))
177177

178178
#define DELAY_CYCLES_VAR DELAY_CYCLES
179179

0 commit comments

Comments
 (0)