I am having trouble with the PWM. While it works, the resolution is very coarse. With 64kHz, the duty cycle (measured with a scope) stays the same for set values 0.51 … 0.56 (it seems to take 6.4% steps). with 32 kHz this is 3.2%. Indicating there is a fixed 1µs hiding somewhere.
I did try fast_PWM, however this killed the CAN bus.
Any suggestions ?
Code is fairly simple:
PwmOut PWM_Power(PA_9); float switching_frequency = 50e3; PWM_Power.period(1.0/switching_frequency); PWM_Power.write(0.66);
Using Visual Studio Code with PlatformIO.
platform = ststm32
board = bluepill_f103c8
framework = mbed
build_flags = -D PIO_FRAMEWORK_MBED_RTOS_PRESENT
PS: really liking the experience with mbed so far!