Skip to content

Commit 23cc84d

Browse files
committed
pwm: rp1: Correct period off-by-1 error
Correct the set_period method to pass (period - 1), as required by the PIO state machine. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
1 parent 6ae851b commit 23cc84d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/pwm/pwm-pio-rp1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static inline void pwm_program_init(PIO pio, uint sm, uint offset, uint pin)
8383
/* Write `period` to the input shift register - must be disabled */
8484
static void pio_pwm_set_period(PIO pio, uint sm, uint32_t period)
8585
{
86-
pio_sm_put_blocking(pio, sm, period);
86+
pio_sm_put_blocking(pio, sm, period - 1);
8787
pio_sm_exec(pio, sm, pio_encode_pull(false, false));
8888
pio_sm_exec(pio, sm, pio_encode_out(pio_isr, 32));
8989
}

0 commit comments

Comments
 (0)