STM32F446RE driver init fail

this is my own circuit board and I already test that each pin can control MOSFET that attached to the motor.

but.

#include <Arduino.h>
// BLDC driver standalone example
#include <SimpleFOC.h>

// BLDC driver instance
BLDCDriver6PWM driver = BLDCDriver6PWM(PA8, PB13, PA9, PB14, PA10, PB15, PB5);

void setup() {
  
  // pwm frequency to be used [Hz]
  // driver.pwm_frequency = 20000;
  // power supply voltage [V]
  driver.voltage_power_supply = 48;
  // Max DC voltage allowed - default voltage_power_supply
  driver.voltage_limit = 10;
  // daad_zone [0,1] - default 0.02 - 2%
  driver.dead_zone = 0.05;

  // driver init
  if(driver.init());
  else{
    digitalWrite(PB13,HIGH);
    digitalWrite(PA8,LOW);
    while (true)
    {

    }
  }

  // enable driver
  driver.enable();

  _delay(1000);
}

void loop() {
    // setting pwm
    // phase A: 3V, phase B: 6V, phase C: 5V
    driver.setPwm(3,6,5);
}

in this code, it stuck at else{while(true)} it tell me that driver.init() was fail.

I am using STM32F446RE custom board. I told that if I try control each pin, it works well.

so I guess it’s not a hardware issues. I checked they are right pin for 6PWM form documents.

please know me why.

I’m very thanks for your help.

I solved it that I change mode 6PWM to 3PWM with DRV8320 MODE pin.

it doesn’t init in 6PWM but at 3PWM it works well.

Hey @Seol_Kim,

I’m happy to hear that you found a way around the problem.

The 6pwm code should work though, so I’d be curious to know why it doesnt.
Could you please add at the beggining of your setup function

Serial.begin(115200);
SimpleFOCDebug::enable(&Serial);

And show us the logs from the serial terminal?

I’m very sorry that I was late to your reply @Antun_Skuric

MOT: Init not possible, driver not initialized
MOT: Align sensor.
MOT: Failed to notice movement
MOT: Init FOC failed.
Motor ready.
Set the target current using serial terminal:

this is the log if I modify code with your want.
(It isn’t quite same from first code, I’m on testing closed loop work)

I guess there isn’t any hint for problem.

Hey @Seol_Kim,

This is very interesting. The pins look good so I am not sure why this message is there:

Could you please put these lines at the beginning of your setup function.

Serial.begin(115200);
SimpleFOCDebug::enable(&Serial);

And copy the entire ouput in the serial. :smiley:

This way the library will output the logs from the driver.init() as well and tell us why it was not initialised.

@Antun_Skuric I say that I modify my code with your advice.

I try it again for you and me. with the code from first

#include <Arduino.h>
// BLDC driver standalone example
#include <SimpleFOC.h>
#include <SoftwareSerial.h>
SoftwareSerial ext_port(PA3, PA2);
// I have to use softwareSerial cuz I didn't make USB serial port for my own board.

// BLDC driver instance
// BLDCDriver3PWM driver = BLDCDriver3PWM(PA8, PA9, PA10, PB13, PB14, PB15);
// #define DRV_EN PB5  // this one works very well with give high to DRV_EN pin

BLDCDriver6PWM driver = BLDCDriver6PWM(PA8, PB13, PA9, PB14, PA10, PB15, PB5);


void setup() {

  ext_port.begin(115200);
  SimpleFOCDebug::enable(&ext_port);
  
  // pinMode(DRV_EN,OUTPUT);
  // digitalWrite(DRV_EN,HIGH);

  // pwm frequency to be used [Hz]
  // driver.pwm_frequency = 20000;
  // power supply voltage [V]
  driver.voltage_power_supply = 48;
  // Max DC voltage allowed - default voltage_power_supply
  driver.voltage_limit = 8;
  // daad_zone [0,1] - default 0.02 - 2%
  // driver.dead_zone = 0.05;

  // driver init
  if(driver.init());
  else{
    ext_port.println("Driver init fail // message for check my self");
    while (true)
    {

    }
  }

  // enable driver
  driver.enable();

  _delay(1000);
}

void loop() {
    // setting pwm
    // phase A: 3V, phase B: 6V, phase C: 5V
    driver.setPwm(3,6,5);
}

and this is the result.

image

no log message with debug enable fuction. T.T

ext_port.println("Driver init fail // message for check my self");

only this message tell me the Serial works well.

I’m not sure if it’s a problem, but I assume SoftwareSerial is bit banging the UART messages, PA2 and PA3 on the f446 are hardware UART pins, so you can use HardwareSerial instead.

Is it 100% sure you’re on the MCU model STM32F446RE? It’s an original chip?
Because the pins you are using should definately work for 6-PWM on the F446…

Can you know me the Arduino define of PA2, PA3 hardware serial name?

I try Serial1, Serial2 but I think they are not.

I use genericSTM32F446RE on PlatformIO

Thanks to your advice.

Yeah, I trust that I can read english and number.

this is my own board’s MCU photo.

If you need, I can send one of it.

I made this 4pcs.

Here is where the used pins are definied in software (it is a bit hard to read though :D)

You could also do something like this:

HardwareSerial Serial2(PA2, PA3);

And then use Serial2 as usual.

Also I am not sure if this is the case at the moment, but if you are using Arduino IDE, at some point you needed to enable the hardware serials in the board options. Navigate to menu where you selected the board and check if there is an option to enable/disable hardware serial. This might be causing you not to see Serial2 by default.

In platformio.ini do you have the option lib_archive = false?