STM32F446RE + TMC6300 6PWM no movement


I feel bit silly and braindead at this point.

So some of you have seen my project SmartKnob.
After switch to STM32 board i have made everything works (screen, sensor, blows and whistles) but the driver & motor, i took for granted that it will work out of box, like it did with my esp32.

I am using
STM32F446RE - MCU (Nucleo64)
TMC6300 - Driver
Arduino STM_CORE by ST
6PWM Driver in simple foc

Power on, 5V supplied to TMC6300.
SimpleFoc test program on open-loop velocity

Pin Config:

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

Compile, upload… nothing
Power draw 0.004A just.
Upon rotating motor by hand TMC6300 board diag light light up (so driver is fine)

Motor doesnt stall, doesnt draw any current,
I’m confident i have everything hooked up correctly.

Unfortunately don’t have oscilloscope to check PWM signal between mcu and driver.

I’m very confused whats wrong, should i have included <variant.h> of some sort to work with STM32 ?

Hooking it back up to ESP32 works.

Full Code:

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

// BLDC motor & driver instance
// BLDCMotor motor = BLDCMotor(pole pair number);
BLDCMotor motor = BLDCMotor(7);
BLDCDriver6PWM driver = BLDCDriver6PWM(PA8, PB13, PA9, PB14, PA10, PB15); //TIM1

//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 = 5;
  // link the motor and the driver

  // limiting motor movements
  motor.voltage_limit = 2;   // [V]
  motor.velocity_limit = 5; // [rad/s] cca 50rpm
  // open loop control config
  motor.controller = MotionControlType::velocity_openloop;

  // init motor hardware

  // add target command T
  command.add('T', doTarget, "target velocity");

  Serial.println("Motor ready!");
  Serial.println("Set target velocity [rad/s]");

void loop() {

  // open loop velocity movement
  // using motor.voltage_limit and motor.velocity_limit

  // user communication;

The STM32G446 should be well supported. Are you using PlatformIO or ArduinoIDE?
Does it print any output to the serial console that you could share? It would be interesting to see which timer combination it finds on these pins…

I use ArduinoIDE, however i found some of your older posts stating that ArduinoIDE potentially does not compile properly therefore can PWM behaviour can be unexpeced - that being said you advised to use PlatformIO instead. Not sure if this is still the case.

I have noticed that eg. PWM control of WS2812 (Neopixel) is also wonky.

So i tried PlatformIO, nothing
Tried 2nd driver board, nothing

Your target voltage is set to zero. After uploading you are sending a command for a desired voltage e.g. T2?

Correct! Default Target voltage is 0
Upon sending serial command eg. T2 there is no reaction from the motor.

Hey, if using PlatformIO, you need the option lib_archive=false

Once you have that, you can add some -D parameters:

build_flags = 

And enable debug in the setup:


Now you should have some serial output on the serial monitor if you monitor the USB of the ST-Link.

Could you post the output produced by the STM32 driver? Lets see what the driver initialisation and pin assignment says…

1 Like

I added the lib_archive=false and the flags to plaftormio.ini
Added SimpleFOCDebug::enable() to my setup,

There is nothing in output of serial monitor apart from test procedure println (motor ready etc.)

Hmmm… can you post your code? Are the Serial.begin and debug enable at the start of the setup method, before the driver init?
→ it can be a bit tricky sometimes to start the serial monitor fast enough to see the output… perhaps adding a delay(5000) after the serial.begin can help?

Normally there should be plenty of debug output from the driver intialization in STM32…

1 Like

here goes my output from monitor

TIM1-CH1 TIM1-CH1N TIM1-CH2 TIM1-CH2N TIM1-CH3 TIM8-CH3N score: -6
TIM1-CH1 TIM1-CH1N TIM1-CH2 TIM1-CH2N TIM1-CH3 TIM12-CH2 score: -6
TIM1-CH1 TIM1-CH1N TIM1-CH2 TIM8-CH2N TIM1-CH3 TIM1-CH3N score: -6
TIM1-CH1 TIM1-CH1N TIM1-CH2 TIM8-CH2N TIM1-CH3 TIM8-CH3N score: -6
TIM1-CH1 TIM1-CH1N TIM1-CH2 TIM8-CH2N TIM1-CH3 TIM12-CH2 score: -6
TIM1-CH1 TIM1-CH1N TIM1-CH2 TIM12-CH1 TIM1-CH3 TIM1-CH3N score: -6
TIM1-CH1 TIM1-CH1N TIM1-CH2 TIM12-CH1 TIM1-CH3 TIM8-CH3N score: -6
TIM1-CH1 TIM1-CH1N TIM1-CH2 TIM12-CH1 TIM1-CH3 TIM12-CH2 score: -6
STM32-DRV: best: TIM1-CH1 TIM1-CH1N TIM1-CH2 TIM1-CH2N TIM1-CH3 TIM1-CH3N score: 1 
STM32-DRV: Restarting timer 1
MOT: Init
MOT: Enable driver.
Motor ready!
Set target velocity [rad/s]

Please don’t laugh… Problem occured in Supply Voltage to my driver, although VIO was powered, my crocodile connector to VBAT+ got loose. :man_facepalming:

I was about to say check your wires and hardware. I had this happening multiple times. Best way to stay connected if you do not have test points or an oscilloscope is to attach LEDs with a higher resistor everywhere to make sure all connection points are hot and avoid testing all the time. Then lower the PWM to like 10Hz and you can literally see with naked eye the signals. Once all LEDs are flashing good, you disconnect them, up the frequency and you are good.

Anyway, there are really cheap oscilloscopes under $100, please consider getting one. Make a test lead with a needle or safety pin and a wire and shrink tube. You can use the oscilloscope as a voltmeter, too, by touching the test point with the needle. If you have good eyes, patience, stable hands/fingers and magnifying goggles/glass, this could change your life for under $100. If you only attach an LED to the needle, it would still kind of work.

1 Like

Blame it on bloody cheap breadboard wiring.
I can’t seem to find quality wires. Usually I re solder them with some flexible 22awg silicon wires and that is usually stable enough.

Without this one, I can bet you had no output on PWM pins and that was the real root cause of the issue, not the wires.

I’m not really budget limited, so I’m keen on getting my hands on proper oscilloscope.

Ok, probably I don’t want to invest into Keysight
But was considering 200Mhz Rigol or Siglent.
Is there any option in around 400 euro that might want to recommend?

How about this Siglent.
4. Channel 100mhz

1 Like

Thats a good one, yes.

1 Like

I have the Rigol DS1054Z, like a lot of hobbyists due to the price. I’m happy with it, but the Siglent looks nice too. It has 14Mpts memory. That’s something to watch for maybe, because that’s not a lot.

A 200MHz Rigol with 4 channels is quite a different price class to the Siglent you linked. If your choice is between those two, the Rigol is much better. Did you mean the 2-channel Rigol: MSO2202A-S ?

Incidentally, my next purchase will be one of these:

They also have a nice logic analyser with the same UI.

For my workbench having it right on my mac’s screen seems attractive.

Also consider how much bandwidth you need… for motor control, the signals are in the 1-100kHz range, way under 1MHz. For debugging most microcontroller stuff, including SPI, 50-100MHz is plenty, but a logic analyser is much better for this usually anyways. For really high speed signals (USB, HDMI, WiFi, Ethernet or others) your 200MHz oscilloscope won’t get you very far. So depending on your needs, maybe consider dropping the MHz down in favour of more memory, a touch screen or other cool features that make the oscilloscope nicer/easier to use, or improve its performance in other regards than bandwidth?

In fact, I’m torn between DS1054Z and SDS1104X-U.

Seem that Rigol has more memory, I’m still newbie so not sure how this 10M difference could/would affect me in future.

Also nowadays at least in Europe Rigol comes with all the premium software upgrades included in price.

Another things speaking for Rigol is that it’s software limited 50Mhz but has same internals as 100mhz so can be unlocked with keygen. And seem Rigol is happy with it as they sell a lot of these. But then I would need to buy 100mhz probes…

Silent has better probes it seem. And it’s more modern.

Now bearing in mind that this is my first oscope purchase so anything is a massive upgrade from no scope.

@runger how do you like UI of Rigol? Are the fast access buttons really improve the user experience vs. menu deep diving in Siglent.

Now it’s a matter of me choosing one.

When it comes to lab equipment I’m a big fan of used but high quality instruments. As long as space is not an issue, for example you can get Agilent/HP 54825A for under $500, which brand new used to costs $3000. Unlike shoes and bags, the high end electronics lab equipment doesn’t really age and wear off.

Also, if you thrash a used lab instrument, it’s still a lot cheaper than thrashing a new one.


I live on small island in the middle of nowhere.
Used market is non existing here. Unfortunately.
Eg. We don’t have electronic component stores here, at least not serious ones.