Skip to content

Commit 2e6e91d

Browse files
authored
Merge pull request #4253 from tannewt/rp2040_fix_pwm_reuse
Fix second shared PWM
2 parents 3ea89b8 + 2b163cc commit 2e6e91d

File tree

1 file changed

+2
-1
lines changed
  • ports/raspberrypi/common-hal/pwmio

1 file changed

+2
-1
lines changed

ports/raspberrypi/common-hal/pwmio/PWMOut.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self,
143143
common_hal_pwmio_pwmout_set_frequency(self, frequency);
144144
pwm_set_enabled(slice, true);
145145
} else {
146+
common_hal_pwmio_pwmout_set_frequency(self, frequency);
146147
common_hal_pwmio_pwmout_set_duty_cycle(self, duty);
147148
}
148149

@@ -163,7 +164,7 @@ void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t* self) {
163164
uint32_t channel_mask = _mask(self->slice, self->channel);
164165
channel_use &= ~channel_mask;
165166
never_reset_channel &= ~channel_mask;
166-
uint32_t slice_mask = ((1 << CHANNELS_PER_SLICE) - 1) << (self->slice * CHANNELS_PER_SLICE + self->channel);
167+
uint32_t slice_mask = ((1 << CHANNELS_PER_SLICE) - 1) << (self->slice * CHANNELS_PER_SLICE);
167168
if ((channel_use & slice_mask) == 0) {
168169
target_slice_frequencies[self->slice] = 0;
169170
slice_variable_frequency &= ~(1 << self->slice);

0 commit comments

Comments
 (0)