Add API option to set PIO initial sideset value for PIO state machine initialization #1265

Open
opened 2023-02-17 09:03:35 -06:00 by dlkeng · 1 comment
dlkeng commented 2023-02-17 09:03:35 -06:00 (Migrated from github.com)

There are times with a PIO state machine using sideset values that the jump to the initial_pc should also have the sideset value specified for it as well to ensure the state of any sideset pins. Currently, in pio_sm_init(), when it sets the jump to the initial_pc, it appears to set the sideset pin states to 0. In some situations, this can lead to a momentary glitch on the sideset pins as the PIO state machine starts.

In addition to pio_sm_init(), suggest an alternate pio_sm_init_sideset() allowing the initial state of the sideset pins to be specified.

For example:
void pio_sm_init_sideset(PIO pio, uint sm, uint initial_pc, uint sideset_bit_count, uint sideset_value, const pio_sm_config * config)

In that function, the final call to pio_sm_exec() would be similar to the following:
pio_sm_exec(pio, sm, pio_encode_sideset(sideset_bit_count, sideset_value) | pio_encode_jmp(initial_pc));

An example call to the added function:

// Load the configuration, and jump to the start of the program, with initial sideset states
pio_sm_init_sideset(pio, sm, entry_point, 2, 0b10, &config);
There are times with a PIO state machine using sideset values that the jump to the _initial_pc_ should also have the sideset value specified for it as well to ensure the state of any sideset pins. Currently, in _pio_sm_init()_, when it sets the jump to the _initial_pc_, it appears to set the sideset pin states to 0. In some situations, this can lead to a momentary glitch on the sideset pins as the PIO state machine starts. In addition to _pio_sm_init()_, suggest an alternate _**pio_sm_init_sideset()**_ allowing the initial state of the sideset pins to be specified. For example: `void pio_sm_init_sideset(PIO pio, uint sm, uint initial_pc, uint sideset_bit_count, uint sideset_value, const pio_sm_config * config)` In that function, the final call to _pio_sm_exec()_ would be similar to the following: `pio_sm_exec(pio, sm, pio_encode_sideset(sideset_bit_count, sideset_value) | pio_encode_jmp(initial_pc));` An example call to the added function: ``` // Load the configuration, and jump to the start of the program, with initial sideset states pio_sm_init_sideset(pio, sm, entry_point, 2, 0b10, &config); ```
kilograham commented 2023-02-17 09:08:34 -06:00 (Migrated from github.com)

good point

good point
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#1265
No description provided.