So I have setup a PWM generating firmware on a Bluepill board (STM32F1) to control some ESC's, but when I measured the outcome with the oscilloscope, the pulse width was not as I calculated it. So to be a bit more concrete, I set up my timer as follows:
Code: Select all
// Using TIM4 and corresponding channels
PWMTim->setMode(channel, TIMER_OUTPUT_COMPARE_PWM1, pin);
PWMTim->setOverflow(500, HERTZ_FORMAT); // 500 Hz PWM Signal -> T_period = 2000 us
PWMTim->setCaptureCompare(channel, 1100, MICROSEC_COMPARE_FORMAT); // 1100 ns out of 2000 ns are high
PWMTim->resume();
Where could the mistake be most probably? In the measurement, in the setup code or in some other issue?
Thank you in advance.