use uint32_t not int

fixes issue https://github.com/MarlinFirmware/Marlin/issues/25018
This commit is contained in:
ellensp
2022-11-29 03:22:26 +13:00
committed by InsanityAutomation
parent 7e0478c97d
commit 661abff6e6
+5 -5
View File
@@ -146,11 +146,11 @@ void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
LIMIT(res_pc_temp, 1U, maxtop);
// Calculate frequencies of test prescaler and resolution values
const int f_diff = ABS(f - int(f_desired)),
f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)),
f_fast_diff = ABS(f_fast_temp - int(f_desired)),
f_pc_temp = (F_CPU) / (2 * p * res_pc_temp),
f_pc_diff = ABS(f_pc_temp - int(f_desired));
const uint32_t f_diff = ABS(f - int(f_desired)),
f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)),
f_fast_diff = ABS(f_fast_temp - int(f_desired)),
f_pc_temp = (F_CPU) / (2 * p * res_pc_temp),
f_pc_diff = ABS(f_pc_temp - int(f_desired));
if (f_fast_diff < f_diff && f_fast_diff <= f_pc_diff) { // FAST values are closest to desired f
// Set the Wave Generation Mode to FAST PWM