Skip to content

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

@dlkeng

Description

@dlkeng

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);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions