Unable to run the example drive code in stm32 bluepill

I tried using the simpleFOC library to run a BLDC motor in stm32f103C6 blue pill in arduino ide by dumping Standalone driver 6PWM pulses program inorder to check whether can I get pwm pulse output from controller, the pin used are (PA8, PA9, PB6, PB7, PB8, PB9) but was unable to get the output. Kindly suggest on how do I get the output from the test code given. Kindly help.

Are you sure you don’t have fake chip bluepill?STM32 Clones: The Good, The Bad And The Ugly | Hackaday


Your pin assignment seems incorrect and your stm chip too low on memory. Please check other threads for the pin assignments and memory requirements.

Your MCU is not the “STM32 BluePill” that is reffered in the docs, and you have to read the MCU datasheet to map the timers and figure out the pins to use - I can’t look more into this from my phone, but I suspect this is the issue tou are facing.

Take a look at the following two images and you should see that the timer pins are different across the MCUs


I have a little more time. Please change the pins to the correct ones and it will work. The pins you use are not on the same motor control timer, these are just some random pins. Also please consider getting a C8 version with 64kb flash.

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

Also, the pins for the C6 and C8 or higher are identical.

The C6 version MCU may not have enough flash to hold the compiled code, and the load may fail due to low flash.


Thank you for your valuable insights. I verified the controller it seems legitimate. I tried using the pins suggested
BLDCDriver6PWM driver = BLDCDriver6PWM(PA8, PB13, PA9, PB14, PA10, PB15);
but I am not able to get PWM outputs from the pins instead I am getting waveforms in pins PA11 and PA12. I hereby attach the waveforms for your reference.

1 Like

Let me check.

This is indeed very odd. I doublechecked the pins, and confirm that the correct pinouts are

BLDCDriver6PWM(PA8, PB13, PA9, PB14, PA10, PB15)

Below is the pinout for a Blue Pill with the C6 memory

You can clearly see the T1 timer channels are as described above.

There is either something going on with the code you use or the Bluepill itself is having a problem. This is definitely not normal behavior.


I cross verified with other blue pill board (Stm32f103cbt6) the same result occurs there as well. I have also attached code for your reference.

Could you please try


and try the signals on the six pins on the oscilloscope?


I tried using the above mentioned line driver.setPwm(3,3,3); still didn’t get pwm signal in any of the pins configured

       However I verified whether the PWM pins are working using normal pwm output code (without simple FOC library) where I found that pins PB13, PB14, PB15 are not giving pwm signal but pins PA8, PA9, PA10, PB6, PB7, PB8, PB9 does give pwm signals.

That is very odd and definitely not normal. Well, if it works on those pins, go ahead, use them but it’s not according to the ST documentation.

Could you please send us a picture close up of the MCU you used? I’m very curious to see which one you got on the blue pill board.


Even with the pins capable of giving pwm signal dosn’t produce pwm output when testing with simpleFOC linbrary’s 6 PWM driver example code. I have also affix the image of blue pill board I use.