forked from Archive/PX4-Autopilot
Adjust some scaling factors for more precise PWM output.
This commit is contained in:
parent
59962bc3da
commit
c513f5ade8
|
@ -164,10 +164,10 @@ pwm_timer_init(unsigned timer)
|
|||
rDCR(timer) = 0;
|
||||
|
||||
/* configure the timer to free-run at 1MHz */
|
||||
rPSC(timer) = pwm_timers[timer].clock_freq / 1000000;
|
||||
rPSC(timer) = (pwm_timers[timer].clock_freq / 1000000) - 1;
|
||||
|
||||
/* and update at the desired rate */
|
||||
rARR(timer) = 1000000 / pwm_update_rate;
|
||||
rARR(timer) = (1000000 / pwm_update_rate) - 1;
|
||||
|
||||
/* generate an update event; reloads the counter and all registers */
|
||||
rEGR(timer) = GTIM_EGR_UG;
|
||||
|
@ -234,6 +234,8 @@ up_pwm_servo_set(unsigned channel, servo_position_t value)
|
|||
return -1;
|
||||
|
||||
/* configure the channel */
|
||||
if (value > 0)
|
||||
value--;
|
||||
switch (pwm_channels[channel].timer_channel) {
|
||||
case 1:
|
||||
rCCR1(timer) = value;
|
||||
|
|
|
@ -96,10 +96,10 @@ pwm_timer_init(unsigned timer)
|
|||
rDCR(timer) = 0;
|
||||
|
||||
/* configure the timer to free-run at 1MHz */
|
||||
rPSC(timer) = cfg->timers[timer].clock_freq / 1000000;
|
||||
rPSC(timer) = (cfg->timers[timer].clock_freq / 1000000) -1;
|
||||
|
||||
/* and update at the desired rate */
|
||||
rARR(timer) = 1000000 / cfg->update_rate;
|
||||
rARR(timer) = (1000000 / cfg->update_rate) - 1;
|
||||
|
||||
/* generate an update event; reloads the counter and all registers */
|
||||
rEGR(timer) = GTIM_EGR_UG;
|
||||
|
@ -166,6 +166,8 @@ pwm_channel_set(unsigned channel, servo_position_t value)
|
|||
return;
|
||||
|
||||
/* configure the channel */
|
||||
if (value > 0)
|
||||
value--;
|
||||
switch (cfg->channels[channel].timer_channel) {
|
||||
case 1:
|
||||
rCCR1(timer) = value;
|
||||
|
|
Loading…
Reference in New Issue