Merge pull request #7299 from BooleanMattock/main

Fix to Issue #7224 - Servo update slow due to PWM channel duty cycle update busy-wait
This commit is contained in:
Scott Shawcroft 2022-12-05 12:54:41 -08:00 committed by GitHub
commit d7874e65c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -236,14 +236,6 @@ extern void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t *self, uin
} }
// compare_count is the CC register value, which should be TOP+1 for 100% duty cycle. // compare_count is the CC register value, which should be TOP+1 for 100% duty cycle.
pwm_set_chan_level(self->slice, self->ab_channel, compare_count); pwm_set_chan_level(self->slice, self->ab_channel, compare_count);
// Wait for wrap so that we know our new cc value has been applied. Clear
// the internal interrupt and then wait for it to be set. Worst case, we
// wait a full cycle.
pwm_hw->intr = 1 << self->slice;
while ((pwm_hw->en & (1 << self->slice)) != 0 &&
(pwm_hw->intr & (1 << self->slice)) == 0 &&
!mp_hal_is_interrupted()) {
}
} }
uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t *self) { uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t *self) {