Skip to content

Commit 490f263

Browse files
committed
Added code to reset SM program counter during a restart
1 parent 9d5fbea commit 490f263

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,9 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
498498

499499
void common_hal_rp2pio_statemachine_restart(rp2pio_statemachine_obj_t *self) {
500500
pio_sm_restart(self->pio, self->state_machine);
501-
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);
502504
uint8_t pio_index = pio_get_index(self->pio);
503505
common_hal_rp2pio_statemachine_stop(self);
504506
uint32_t pins_we_use = _current_sm_pins[pio_index][self->state_machine];

0 commit comments

Comments
 (0)