I'm controlling two servos on a F205 based board. I can control them otherwise properly but it looks like there's only something like 10 steps in the full scale.
This is my PWM config:
Code: Select all
static PWMConfig pwmcfg = {
10000, // 10 kHz PWM clock frequency
200, // 50 Hz (20.0 ms) initial frequency
NULL, // No periodic callback.
{
// Enable channels 1 through 2
{PWM_OUTPUT_ACTIVE_HIGH, NULL},
{PWM_OUTPUT_ACTIVE_HIGH, NULL},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL}
},
// HW dependent part
0, // TIM CR2 register initialization data
#if STM32_PWM_USE_ADVANCED
0, // TIM BDTR (break & dead-time) register initialization data.
#endif
};
And I'm setting the duty cycle like this:
Code: Select all
pwmEnableChannel(&PWMD3, pwm, PWM_PERCENTAGE_TO_WIDTH(&PWMD3, duty));Where the duty is something between 500 and 1000. The servo doesn't usually move if I'm adjusting the duty just a bit (~10).
The API documentation is saying this:
Be careful with rounding errors, this is integer math not magic. You can specify tenths of thousandth but make sure you have the proper hardware resolution by carefully choosing the clock source and prescaler settings, see PWM_COMPUTE_PSC.
And even though I understand roughly the meaning of it, I don't understand it in practice.
Any hints what to adjust?
Thanks.