Hi, I am testing with a STM32F103 and realised that PWM frequency is 1 kHz but I would have expected 25 kHz as set in the MCU specific header. I am using platformio and have nothing special in the ini file:
when I click through the code I end up in the correct line in stm32_mcu.cpp (I think).
What is missing / incorrect?
I would also expect that one should use specific pins to use the timers efficiently but couldn’t find any hint - have used according to example
BLDCDriver3PWM driver = BLDCDriver3PWM(PB6, PB7, PB8, PB5);
It’s some kind of difference in the compiler setups.
SimpleFOC supports many kinds of hardware, and has implementations for the PWM-driver functions for each hardware type (AtmelAVR, STM32, SAMD21, RP2040, etc).
There is also a “generic” implementation which just uses analogWrite() and relies on the Arduino framework to set the PWM. This results in the bad 1kHz PWM performance on most boards.
The code selects the correct option using a C/C++ construct called “weak bindings”.
When using platformIO, you need this option, or the linker gets confused and incorrectly binds the generic, weakly bound implementation.
When using ArduinoIDE the linker does the right thing and binds the hardware-specific implementation by default.