Closed ser-plu closed 1 year ago
Do you want to propose a fix?
I just ran into the same issue; hacky workaround is:
using Timer = Timer1;
Timer::enable();
Timer::setMode(Timer::Mode::UpCounter);
// Timer clock: APB2 timer clock (170MHz)
Timer::setPrescaler(10);
// Prescaler: 1 -> Timer counter frequency: 170MHz
Timer::setOverflow(4250);
// Pwm frequency: 170MHz / 4250 / 10 = 4kHz
// configureOutputChannel for ChXn channels does not work
// Timer::configureOutputChannel<GpioC13::Ch1n>(Timer::OutputCompareMode::Pwm, 0);
// However, the configure output channel with Ch1 pin disabled works as expected
Timer::configureOutputChannel(1,
Timer::OutputCompareMode::Pwm,
Timer::PinState::Disable, // disable Ch1 output
Timer::OutputComparePolarity::ActiveHigh, // this doesn't matter
Timer::PinState::Enable, // enable Ch1n output
Timer::OutputComparePolarity::ActiveHigh, // OutputComparePolarity for Ch1n
Timer::OutputComparePreload::Disable
);
Timer::applyAndReset();
Timer::setCompareValue(1,0);
Timer::applyAndReset();
Timer::pause();
Timer::enableOutput();
Timer::connect<GpioC13::Ch1n>(); // it works to just connect the Ch1n channel
Timer::start();
This has been fixed, right?
configureOutputChannel
function from simple timers (cannot enable the complementary channel).configureOutputChannel
fromAdvancedControlTimer
is more appropriate. There could be also more similarities between the timers.GeneralPurposeTimer::signalToChannel
does not work with complementary channels. Need to add|| Signal::Signal == Gpio::Signal::Ch1n
to every if check.