PWM pins are incorrectly mapped

I’m using Nucleo-STM32G431RB and the board controller from the Infineon PMSM_LV_15W_Card. All the physical wiring and pin assignment are correctly matched with 6 PWM pins capabilities, but the Software initialization tell me that some pins don’t support Timer for PWM (Pin 26 = PB10). While based on ST Datasheet that pin support for PWM.

Serial Monitor Output:

This is my platform.ini:

[env:nucleo_g431rb]
platform = ststm32
board = nucleo_g431rb
framework = arduino
debug_tool = stlink
monitor_speed = 115200
upload_protocol = stlink
lib_deps = askuric/Simple FOC@^2.3.4
lib_archive = false

My Code:

#include <Arduino.h>
#include <SimpleFOC.h>

/* Hall Sensor Pins */
#define PIN_HALL_A PA_0
#define PIN_HALL_B PA_1
#define PIN_HALL_C PA_4

/* BLDC Driver Pins */
#define PIN_PWM_LIN1 PB_3
#define PIN_PWM_LIN2 PB_4
#define PIN_PWM_LIN3 PB_10

#define PIN_PWM_HIN1 PC_7
#define PIN_PWM_HIN2 PB_6
#define PIN_PWM_HIN3 PA_7

/* Current Sense Pins */
#define PIN_ADC_IU PB_0
#define PIN_ADC_IV PC_1
#define PIN_ADC_IW PC_0

/* Motor Characteristics*/
#define POLE_PAIRS 4
#define PHASE_RESISTANCE 6.85 // (13.7 / 2)
#define PHASE_INDUCTANCE 3.865 // (7.73 / 2)
#define KV_RATING 195

/* Current Sense */
#define SHUNT_RESISTOR 0.05
#define GAIN_AMPLIFIER 16.4

// BLDCMotor( pole_pairs , ( phase_resistance, KV_rating optional) )
BLDCMotor motor = BLDCMotor(POLE_PAIRS, PHASE_RESISTANCE, KV_RATING, PHASE_INDUCTANCE);

// BLDCDriver6PWM( pin_pwmAH, pin_pwmAL, pin_pwmBH, pin_pwmBL, pin_pwmCH, pin_pwmCL, enable (optional))
BLDCDriver6PWM driver = BLDCDriver6PWM(PIN_PWM_HIN1, PIN_PWM_LIN1, PIN_PWM_HIN2, PIN_PWM_LIN2, PIN_PWM_HIN3, PIN_PWM_LIN3);

// HallSensor(int hallA, int hallB , int hallC , int pole pairs)
HallSensor sensor = HallSensor(PIN_HALL_A, PIN_HALL_B, PIN_HALL_C, POLE_PAIRS);

// LowsideCurrentSense(shunt_resistance, gain, adc_a, adc_b, adc_c)
LowsideCurrentSense current_sense = LowsideCurrentSense(SHUNT_RESISTOR, GAIN_AMPLIFIER, PIN_ADC_IU, PIN_ADC_IV, PIN_ADC_IW);

// Interrupt routine initialization
// channel A and B callbacks
void doA(){sensor.handleA();}
void doB(){sensor.handleB();}
void doC(){sensor.handleC();}

void setup() {
Serial.begin(115200); // use monitoring with the BLDCMotor
SimpleFOCDebug::enable(&Serial);

/* Initialize Hall Sensor */
sensor.init(); // initialize encoder hardware
sensor.enableInterrupts(doA, doB, doC); // hardware interrupt enable
motor.linkSensor(&sensor); // link the motor to the sensor

/* Initialize BLDC Driver */
driver.pwm_frequency = 20000; // pwm frequency to be used [Hz]
driver.voltage_power_supply = 18; // power supply voltage [V]
driver.voltage_limit = 18; // Max DC voltage allowed - default voltage_power_supply
int driverStatus = driver.init(); // driver init
Serial.printf(“Driver init status %d\n”, driverStatus);
motor.linkDriver(&driver); // link the motor to the driver

// current_sense.linkDriver(&driver); // link the driver with the current sense
// motor.linkCurrentSense(&current_sense); // link the motor to current sense
// motor.useMonitoring(Serial); // monitoring port

// motor.controller = MotionControlType::velocity; // set control loop type to be used
// motor.init(); // initialize motor
// current_sense.init(); // init current sense

// // align encoder and start FOC
// motor.initFOC();
}

void loop() {
// // FOC algorithm function
// motor.loopFOC();

// // velocity control loop function
// // setting the target velocity to 2rad/s
// motor.move(2);

// // monitoring function outputting motor variables to the serial terminal
// motor.monitor();
}

After changing the PB10 to other pin it appears as follow:

Thank you in advance!

6PWM is very tricky and sensitive. Ensuring that all pins are capable of generating PWM is not enough.

You should make sure either to use the same timer for all 6 pins (typically timers 1 or 8) or have one timer per phase (per high/low pwm pair).

I believe that your pins do not blong to any of the two categories. Am I missing something?

Here is a link to our pin mapping docs for your stm32 variant: G431R(6-8-B)(I-T)_G441RB(I-T) Pinout | STM32 Pinouts

Here is the docs section that talks about choosing PWM pins for stm32.