From f9e1fc119dfd08a6c383bc6572e1acd933578c98 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 23 Aug 2022 15:17:54 -0500 Subject: [PATCH] Fix handling of zero-length pulseout pulse --- ports/nrf/common-hal/pulseio/PulseOut.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ports/nrf/common-hal/pulseio/PulseOut.c b/ports/nrf/common-hal/pulseio/PulseOut.c index 1c3c317a05..d282043be7 100644 --- a/ports/nrf/common-hal/pulseio/PulseOut.c +++ b/ports/nrf/common-hal/pulseio/PulseOut.c @@ -74,6 +74,11 @@ static void pulseout_event_handler(nrf_timer_event_t event_type, void *p_context nrfx_timer_pause(timer); pulse_array_index++; + // Ignore a zero-length pulse + while (pulse_array[pulse_array_index] == 0 && + pulse_array_index < pulse_array_length) { + pulse_array_index++; + } // No more pulses. Turn off output and don't restart. if (pulse_array_index >= pulse_array_length) {