Skip to content

When configuring the timer in PWM input mode, it is not possible to use the free channels as PWM output #810

Open
@faunel

Description

@faunel

When using the timer in PWM input mode, channels 1 and 2 will be used as inputs.
However, channels 3 and 4 remain free, but they cannot be used as PWM output.

Previously, in version 0.21.0, this was not possible because the timer was moved to the ownership of the pwm_hz method.

let tim3 = Timer::new(dp.TIM3, &clocks);
tim3.pwm_hz(10.kHz());

// tim3 move to pwm_hz
// So, it's not possible to do this
tim3.pwm_input(1.kHz(), pwm_reader_ch1);

I thought that with the new version 0.22.0, where the timer is split into a PWM manager and channels, this would be possible.
But it still doesn't work.

let pwm_reader_ch1: Pin<'B', 4> = gpiob.pb4.into_pull_down_input();
let tim3 = Timer::new(dp.TIM3, &clocks);
let (mut pwm_mngr, (_ch1, _ch2, ch3, ch4)) = tim3.pwm_hz(10.kHz());
let mut ch3 = ch3.with(gpiob.pb0);
ch3.enable();
ch3.set_duty(50);

// Error: cannot move out of dereference of `PwmHzManager<stm32f4xx_hal::pac::TIM3>`
let monitor: timer::PwmInput<TIM3> = pwm_mngr.pwm_input(1.kHz(), pwm_reader_ch1);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions