mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-26 09:36:13 +01:00
STM32 reinstate 100% duty cycle PWM
This commit is contained in:
parent
7afd4443d6
commit
2ff1619ad1
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user