Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4883

General • Re: Setting X or Y PIO registers when FIFO is joined

$
0
0
I am using sm_config_set_fifo_join to join the FIFO, but I am using the function pio_sm_init to set the config ad initialise the state machine. I checked the SDK documentation and found the function pio_sm_set_config. However, none of the example programs in the examples repository show usage of this.
I understand that pio_sm_set_config just associates a SM with a configuration, but does not 'initialise' it. Is my understanding correct.
Yes. pio_sm_set_config() is in fact called by pio_sm_init(). So you could use pio_sm_init() to set up an initial configuration, do the register setting, then tweak the configuration and use pio_sm_set_config() to use your new configuration without resetting everything.
Also, to force execute PIO code to set the x/y/OSR registers, should the SM be running (I assume so, but checking)?
No. Or to be precise, you _can_ do it while the machine is running, but that complicates things (as the running program may mess with the resources you are trying to use with forced instructions). Much easier to do it while the machine is stopped.

If you force instructions into a running machine, they execute in between the instructions of the program (the program gets paused for 1 clock tick, your instruction executes, then the next instruction of the running program executes before you have a chance to do anything else).
If you force instructions into a stopped machine, your instructions run one after another with the machine paused in between.

Statistics: Posted by arg001 — Sat Dec 28, 2024 7:14 pm



Viewing all articles
Browse latest Browse all 4883

Trending Articles