NUCLEO-F302R8 can not run BLDC driver standalone test

I’m using my NUCLEO STM32F302R8 board to run the open_loop_velocity_example, but the serial didn’t work and the motor can not run.

I found my problem similar to NUCLEO STM32F302R8 can not run. So I changed the pins into (PC0, PC2, PC3, PA9),which all uses TIM1, now the serial worked perfectly, but the motor still didn’t run.

So I tried the BLDC_driver_3PWM_standalone project, with the setting of (PC0, PC2, PC3, PA9), but the voltages of PWM A\B\C are all 12V, which is the same as the power supply voltage. This result was not ideal since my code was

I tried other combination of pins,but none of these worked well, such as:
PC0, PC2, PC3, PA9

PC0, PA9, PC2,PC3

PA8, PA9, PA10,PA11

BTW, I’m not sure if the sequence of the timer channel settings has influence on the output,for example:(TIM1-CH1 TIM1-CH3 TIM1-CH4 TIM1-CH2)&(TIM1-CH1 TIM1-CH2 TIM1-CH3 TIM1-CH4), does the sequence has to be (CH1 CH3 CH4 CH2)?

Also, I tried the TIM2 pins, but this time the code stopped at driver.init()
PA0, PA1, PA3, PB10

I also tried to remove file stm32_mcu.cpp completely and remove line 11(mine is 13) from generic_mcu.cpp . It didn’t change anything.

I hope that I provided enough information and I am looking forward to a reply.



Are you using this with simplefoc board for driver?

Are you starting with the openloop velocity example as a starting point? Perhaps you can post your code.

I’m using simplefoc board v2.0.2 for driver, and here’s the open loop velocity code:

// Open loop motor control example
#include <SimpleFOC.h>

// BLDC motor & driver instance
// BLDCMotor motor = BLDCMotor(pole pair number);
BLDCMotor motor = BLDCMotor(7,3.83);
// BLDCDriver3PWM driver = BLDCDriver3PWM(pwmA, pwmB, pwmC, Enable(optional));
BLDCDriver3PWM driver = BLDCDriver3PWM(PC0, PC2, PC3, PA9);

//target variable
float target_velocity = 0;

// instantiate the commander
Commander command = Commander(Serial);
void doTarget(char* cmd) { command.scalar(&target_velocity, cmd); }

void setup() {

  // driver config
  // power supply voltage [V]
  driver.voltage_power_supply = 12;
  // link the motor and the driver
  // limiting motor movements
  motor.voltage_limit = 8;   // [V]
  motor.velocity_limit = 50;
  // open loop control config
  motor.controller = MotionControlType::velocity_openloop;
  // init motor hardware
  // add target command T
  command.add('T', doTarget, "target velocity");
  Serial.print("Motor ready!");
  Serial.print("Set target velocity [rad/s]");
void loop() {
  // open loop velocity movement
  // using motor.voltage_limit and motor.velocity_limit
  // user communication;

and the driver standalone test code

// BLDC driver standalone example
#include <SimpleFOC.h>
// BLDC driver instance
BLDCDriver3PWM driver = BLDCDriver3PWM(PC0, PC2, PC3, PA9);

void setup() {
  // pwm frequency to be used [Hz]
  // for atmega328 fixed to 32kHz
  // esp32/stm32/teensy configurable
  driver.pwm_frequency = 50000;
  // power supply voltage [V]
  driver.voltage_power_supply = 12;
  // Max DC voltage allowed - default voltage_power_supply
  driver.voltage_limit = 12;

  // driver init

  // enable driver


void loop() {
    // setting pwm
    // phase A: 3V
    // phase B: 6V
    // phase C: 5V

Why do you have that 1000ms delay in loop? The move needs to be called regularly. Don’t use any delay.
Maybe you can give a non zero target velocity (in case serial rx is the issue) e.g

float target_velocity = 1;

Until i get movement in cautious about setting voltage_limit e.g i might go for 2 rather than 8.

What are you seeing? The motor is not moving but is it holding its position? Is it drawing much current/getting hot?

Hi @Hsia_0824 do you have an update on this?

I am just starting out and have the F302R8 board and can’t get an output from the standalone test either. I have deleted the optional pin from the end of the BLDCDriver Line and have nothing attached to the board but can’t seem to get an output.

Many thanks to any others who can advise! (apologies as always for next to no knowledge and if this answer is elsewhere)