From 0c45a28d24e1a7f9ea5912c928d7b5a860a6514a Mon Sep 17 00:00:00 2001 From: robert-hh Date: Sun, 24 Jul 2022 09:15:38 +0200 Subject: [PATCH] rp2/rp2_pio: Fix StateMachine.restart when PIO program is shared. The state machines were not properly restarted in the case that the same PIO program was shared among multiple StateMachine instances. This is because only the first StateMachine to use the program would set the rp2_state_machine_initial_pc variable. See https://forum.micropython.org/viewtopic.php?f=21&t=12776&p=69464#p69464 --- ports/rp2/rp2_pio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/rp2/rp2_pio.c b/ports/rp2/rp2_pio.c index 072644eba6..eb85eb2248 100644 --- a/ports/rp2/rp2_pio.c +++ b/ports/rp2/rp2_pio.c @@ -469,8 +469,8 @@ STATIC mp_obj_t rp2_state_machine_init_helper(const rp2_state_machine_obj_t *sel if (offset < 0) { rp2_pio_add_program(&rp2_pio_obj[PIO_NUM(self->pio)], args[ARG_prog].u_obj); offset = mp_obj_get_int(prog[PROG_OFFSET_PIO0 + PIO_NUM(self->pio)]); - rp2_state_machine_initial_pc[self->id] = offset; } + rp2_state_machine_initial_pc[self->id] = offset; // Compute the clock divider. uint16_t clkdiv_int;