Skip to content

Commit c268597

Browse files
authored
Merge pull request #4987 from DavePutz/issue_4983
Fix for Issue #4983 - stop state machine before restarting
2 parents c6669e2 + 5c9823d commit c268597

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ports/raspberrypi/common-hal/rp2pio/StateMachine.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,11 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
497497
}
498498

499499
void common_hal_rp2pio_statemachine_restart(rp2pio_statemachine_obj_t *self) {
500+
common_hal_rp2pio_statemachine_stop(self);
501+
// Reset program counter to the original offset. A JMP is 0x0000 plus
502+
// the desired offset, so we can just use self->offset.
503+
pio_sm_exec(self->pio, self->state_machine,self->offset);
500504
pio_sm_restart(self->pio, self->state_machine);
501-
502505
uint8_t pio_index = pio_get_index(self->pio);
503506
uint32_t pins_we_use = _current_sm_pins[pio_index][self->state_machine];
504507
pio_sm_set_pins_with_mask(self->pio, self->state_machine, self->initial_pin_state, pins_we_use);

0 commit comments

Comments
 (0)