Browse Source

🐛 [LCP1768] Init PWM in set_pwm_duty (#23110)

Mike La Spina 3 years ago
parent
commit
649c7685bf
No account linked to committer's email address
1 changed files with 3 additions and 1 deletions
  1. 3
    1
      Marlin/src/HAL/LPC1768/fast_pwm.cpp

+ 3
- 1
Marlin/src/HAL/LPC1768/fast_pwm.cpp View File

@@ -25,7 +25,9 @@
25 25
 #include <pwm.h>
26 26
 
27 27
 void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
28
-  LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size);
28
+  if (!LPC176x::pin_is_valid(pin)) return;
29
+  if (LPC176x::pwm_attach_pin(pin)) 
30
+    LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size);  // map 1-254 onto PWM range
29 31
 }
30 32
 
31 33
 #if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM

Loading…
Cancel
Save