Skip to content

Commit 8d79d4e

Browse files
committed
Ensure pin is left low after PulseOut
1 parent 3c25d8e commit 8d79d4e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ports/raspberrypi/common-hal/pulseio/PulseOut.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "shared-bindings/microcontroller/__init__.h"
3535
#include "common-hal/pwmio/PWMOut.h"
3636
#include "supervisor/shared/translate.h"
37+
#include "src/rp2040/hardware_structs/include/hardware/structs/pwm.h"
3738
#include "src/rp2_common/hardware_pwm/include/hardware/pwm.h"
3839
#include "src/common/pico_time/include/pico/time.h"
3940

@@ -130,7 +131,12 @@ void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t *self, uint16_t *pu
130131
// signal.
131132
RUN_BACKGROUND_TASKS;
132133
}
133-
// Short delay to give pin time to settle before disabling PWM
134-
common_hal_mcu_delay_us(min_pulse);
134+
// Ensure pin is left low
135+
pwm_hw->slice[self->slice].ctr = 0;
136+
pwm_hw->slice[self->slice].cc = 0;
137+
pwm_hw->slice[self->slice].top = 0;
138+
pwm_hw->slice[self->slice].div = 1u << PWM_CH0_DIV_INT_LSB;
139+
pwm_hw->slice[self->slice].csr = PWM_CH0_CSR_EN_BITS;
140+
pwm_hw->slice[self->slice].csr = 0;
135141
pwm_set_enabled(self->slice,false);
136142
}

0 commit comments

Comments
 (0)