diff options
| author | Scott Shawcroft <scott@adafruit.com> | 2021-02-26 11:53:54 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-26 11:53:54 -0800 |
| commit | 2e6e91dc5c15b7439750f391665c20053bfc1b35 (patch) | |
| tree | 27fc6886c6d5c1ed0e949cfe74bf8ec1801f6a81 | |
| parent | 3ea89b86c1e65457af6dfc3b1f089e6f5535df88 (diff) | |
| parent | 2b163ccd6a9f934a71cd8450b385977fb009bff5 (diff) | |
Merge pull request #4253 from tannewt/rp2040_fix_pwm_reuse
Fix second shared PWM
| -rw-r--r-- | ports/raspberrypi/common-hal/pwmio/PWMOut.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/ports/raspberrypi/common-hal/pwmio/PWMOut.c b/ports/raspberrypi/common-hal/pwmio/PWMOut.c index 00b461880..f690528ae 100644 --- a/ports/raspberrypi/common-hal/pwmio/PWMOut.c +++ b/ports/raspberrypi/common-hal/pwmio/PWMOut.c @@ -143,6 +143,7 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self, common_hal_pwmio_pwmout_set_frequency(self, frequency); pwm_set_enabled(slice, true); } else { + common_hal_pwmio_pwmout_set_frequency(self, frequency); common_hal_pwmio_pwmout_set_duty_cycle(self, duty); } @@ -163,7 +164,7 @@ void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t* self) { uint32_t channel_mask = _mask(self->slice, self->channel); channel_use &= ~channel_mask; never_reset_channel &= ~channel_mask; - uint32_t slice_mask = ((1 << CHANNELS_PER_SLICE) - 1) << (self->slice * CHANNELS_PER_SLICE + self->channel); + uint32_t slice_mask = ((1 << CHANNELS_PER_SLICE) - 1) << (self->slice * CHANNELS_PER_SLICE); if ((channel_use & slice_mask) == 0) { target_slice_frequencies[self->slice] = 0; slice_variable_frequency &= ~(1 << self->slice); |
