I'm not sure what I should be asking for because some of the terminology is confusing to me, but what I'm trying to do is use the two motor timers (TIM1 and TIM8) on the STM32F405 to sample BEMF on a sensorless BLDC driver.

On a previous version of this hardware, I was using an F411 and only driving one motor, so what I was doing was the following:

  1. Set up the hardware timer PWM outputs of TIM1 to drive the gate driver (CH1, CH1N, CH2, CH2N, CH3 CH3N)
  2. Set up the timer to run at 20kHz and change the duty cycle using a PI controller. PWM is driven using Center Aligned Mode 3.
  3. Set up CH4 of TIM1 to count to 1. Use this event to trigger an ADC injected conversion of the 3 BEMF resistors.

This works OK, albeit rather hackey....I know that's not right, but it was working.

However, now that I'm trying to drive two motors with two different motor timers, I can't lean on this same method because I'm not allowed to sample more than 4 injected conversions at a time....What is the right way to use two motor timers to drive two independent BLDC motors and grab the required 6 BEMF signals at the top of the center aligned PWM signal?

  • \$\begingroup\$ Why do you say it's not right/hackey? That should be a perfectly legitimate way to make sure your ADC sampling happens when your low side FETs are on. I do something very similar on a STM32-based driver I designed \$\endgroup\$
    – Ocanath
    Dec 11, 2019 at 20:10

1 Answer 1


The STM32F405 has three independent AD converters, which can be triggered by a variety of sources.

  • You already have a working configuration of TIM1 and ADC1 which controls motor 1.
  • Set up TIM8 channels 1-3 to output the PWM signals for motor 2, and generate the sampling pulse on channel 4.
  • Set up ADC2 to do an injected conversion sequence of the three BEMF signals from motor 2.
  • Set the JEXTSEL bits of ADC2->CR2 to 1110 to use Timer 8 Channel 4 as a trigger for the injected conversion sequence.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.