From b662dd1f9221bc1a489dfb84737a49564f72858f Mon Sep 17 00:00:00 2001 From: Mike La Spina Date: Fri, 12 Nov 2021 12:14:28 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20[LCP1768]=20Init=20PWM=20in=20se?= =?UTF-8?q?t=5Fpwm=5Fduty=20(#23110)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/LPC1768/fast_pwm.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Marlin/src/HAL/LPC1768/fast_pwm.cpp b/Marlin/src/HAL/LPC1768/fast_pwm.cpp index 70fc0e333d..197abb3310 100644 --- a/Marlin/src/HAL/LPC1768/fast_pwm.cpp +++ b/Marlin/src/HAL/LPC1768/fast_pwm.cpp @@ -25,7 +25,9 @@ #include void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { - LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); + if (!LPC176x::pin_is_valid(pin)) return; + if (LPC176x::pwm_attach_pin(pin)) + LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); // map 1-254 onto PWM range } #if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM