2025-06-14 7:25 PM
Hi everyone,
I'm working with the STM32F446RE and exploring the 6-step BLDC motor control example provided by the STM32 Motor Control SDK. In the CubeMX configuration of the firmware:
3 GPIOs are configured as analog inputs:
M1_BEMF_U → PC3 → ADC1_IN13
M1_BEMF_V → PA7 → ADC1_IN7
M1_BEMF_W → PB0 → ADC1_IN8
However, in the ADC Injected Conversion Mode, only Channel 13 (PC3) is selected and used (1 injected conversion configured).
See image below for reference:
My question is:
Why are all 3 BEMF pins configured in CubeMX if only Channel 13 is used in the ADC injected group?
I expected that all 3 channels would be used in the injected sequence to sample U, V, and W BEMF voltages.
Do they dynamically change the injected channel in code depending on the commutation step? Or is there another reason for this configuration?
Thanks in advance for any clarification!
Solved! Go to Solution.
2025-06-25 2:09 AM
Hi Duc, this specific ADC channel management in CubeMx is currently due to the IOC generation done by the MCSDK WB that set only one injected channel per used ADC. This could be improved in the future. And as you said, at each commutation step, a new BEMF phase signal is checked for zero crossing detection on its specific ADC channel.
Best regards.
Fabrice
2025-06-15 7:39 AM
Hi again,
After reviewing the firmware more closely, I believe I’ve found the answer to my own question, and I’d like to confirm if this is correct:
At each step of the 6-step commutation, the firmware dynamically updates the injected ADC channel to match the floating phase (either U, V, or W) — which is the one from which BEMF needs to be sensed.
This is done using the LL_ADC_INJ_SetSequencerRanks() function.
So even though the ADC could be configured for multiple injected conversions, the firmware uses only 1 injected channel per step, and switches it at runtime based on the commutation step.
This seems efficient and makes sense for sensorless control, but I’d appreciate it if someone could confirm this is the intended behavior in the STM32 Motor Control SDK.
Thanks!
2025-06-24 9:54 AM
Hi Duc, currently the 6-step FW does not take into account the configured ADC injected channel sampling time set either into the STM32CubeMx or MCSDK WB tool. As a matter of fact, the ADC sampling time of each ADC injected channels are re programmed into the BADC_Init function, embedded into the bemf_ADC_fdbk_sixstep.c file, with specific constant values that depend on the STM32 supported IC family. This behavior will be corrected into next MCSDK version. If you need specific sampling time values, i suggest you update the BADC_Init function in consequence.
Best regards.
Fabrice
2025-06-24 6:14 PM
Hi @Fabrice LOUBEYRE , thanks for your reply! I understand the point about ADC sampling time being hardcoded in BADC_Init, and that will be helpful for tuning.
However, my original question was more about why only one ADC injected channel is configured in CubeMX, even though all three BEMF pins (U, V, W) are set as analog inputs. Specifically:
Does the 6-step firmware dynamically switch the injected ADC channel during runtime based on the current commutation step (i.e., to measure back-EMF on the floating phase)? Or is there another reason for this configuration?
I'd appreciate clarification on that dynamic behavior. Thanks again!
2025-06-25 2:09 AM
Hi Duc, this specific ADC channel management in CubeMx is currently due to the IOC generation done by the MCSDK WB that set only one injected channel per used ADC. This could be improved in the future. And as you said, at each commutation step, a new BEMF phase signal is checked for zero crossing detection on its specific ADC channel.
Best regards.
Fabrice