-
Notifications
You must be signed in to change notification settings - Fork 51
Description
I have an existing board with a STM32G431Rx
. I need to drive a PWM at pin C11
. C11 is the complementary output of Timer8_Channel2.
Additionally, I'd like to drive a PWM at pin B6
. B6 is Timer8_Channel1.
Driving only B6 should be easy:
let b6 = gpiob.pb6.into_alternate::<AF5>();
let mut pwm = dp.TIM8.pwm(b6, 1_000_u32.Hz(), &mut rcc);
I'm struggling to drive just C11.
let c11 = gpioc.pc11.into_alternate::<AF4>();
let mut pwm = dp.TIM8.pwm(c11, 1_000_u32.Hz(), &mut rcc);
error[E0277]: the trait bound `PC11<Alternate<4>>: Pins<Periph<RegisterBlock, 1073820672>, _, _>` is not satisfied
--> src/main.rs:438:31
|
438 | let mut pwm = dp.TIM8.pwm(c11, 1_000_u32.Hz(), &mut rcc);
| --- ^^^ unsatisfied trait bound
| |
| required by a bound introduced by this call
It compiles when I use one of the primary pins for Tim8Ch2:
let c11 = gpioc.pc11.into_alternate::<AF4>();
let pin_dummy_pwm = gpioc.pc7.into_alternate();
let mut pwm = dp.TIM8.pwm(pin_dummy_pwm, 1_000_u32.Hz(), &mut rcc);
pwm.into_complementary(c11);
As I understand it, to use multiple channels of the same timer, I'll need to use tuple syntax. The following compiles (I haven't yet tested any of this on hardware):
let b6 = gpiob.pb6.into_alternate::<AF5>();
let c11 = gpioc.pc11.into_alternate::<AF4>();
let pin_dummy_pwm = gpioc.pc7.into_alternate();
let (mut pwm1, mut pwm2) = dp.TIM8.pwm((b6, pin_dummy_pwm), 1_000_u32.Hz(), &mut rcc);
pwm2.into_complementary(c11);
Unfortunately I actually do need both possible primary pins of timer 8 channel 2 (C7 or A14) for other functionality so I can't just leave them floating and run a dummy PWM on them.
So is it possible to run just the complementary signal, without having to configure the primary pin?