Issue 4237 - Changed initial setting in program_struct #4405
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Although I cannot find it documented anywhere; looking at _pio_find_offset_for_program() in sdk/src/rp2_common/hardware_pio/pio.c, it is checking if the program origin is >= 0 and, if so, using that origin to look for space. As a result, with the default origin of 0 then pio_can_add_program() will fail on the second attempt to add a program. This limits CP to only adding one program per PIO. This was the cause of issue #4237, where the third call to rp2pio.StateMachine() would fail. The fix simply changes the default from 0 to -1.