From 2ff1619ad15ed43bb87eaac23b3c402d5df10923 Mon Sep 17 00:00:00 2001 From: pmantoine Date: Wed, 4 Oct 2023 14:54:06 +0800 Subject: [PATCH] STM32 reinstate 100% duty cycle PWM --- DCCTimerSTM32.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DCCTimerSTM32.cpp b/DCCTimerSTM32.cpp index 0f9c432..f2d51ff 100644 --- a/DCCTimerSTM32.cpp +++ b/DCCTimerSTM32.cpp @@ -306,18 +306,18 @@ void DCCTimer::DCCEXanalogWrite(uint8_t pin, int value) { // Calculate percentage duty cycle from value given uint32_t duty_cycle = (value * 100 / 256) + 1; if (pin_timer[pin] != NULL) { - if (duty_cycle == 100) - { - pin_timer[pin]->pauseChannel(pin_channel[pin]); - DIAG(F("DCCEXanalogWrite::Pausing timer channel on pin %d"), pin); - } - else - { + // if (duty_cycle == 100) + // { + // pin_timer[pin]->pauseChannel(pin_channel[pin]); + // DIAG(F("DCCEXanalogWrite::Pausing timer channel on pin %d"), pin); + // } + // else + // { pinmap_pinout(digitalPinToPinName(pin), PinMap_TIM); // ensure the pin has been configured! - pin_timer[pin]->resumeChannel(pin_channel[pin]); + // pin_timer[pin]->resumeChannel(pin_channel[pin]); pin_timer[pin]->setCaptureCompare(pin_channel[pin], duty_cycle, PERCENT_COMPARE_FORMAT); // DCC_EX_PWM_FREQ Hertz, duty_cycle% dutycycle DIAG(F("DCCEXanalogWrite::Pin %d, value %d, duty cycle %d"), pin, value, duty_cycle); - } + // } } else DIAG(F("DCCEXanalogWrite::Pin %d is not configured for PWM!"), pin);