Skip to content

rp2: Correct bit access for rp2_state_machine_init.#18625

Merged
dpgeorge merged 1 commit into
micropython:masterfrom
bikeNomad:fix-rp2-shiftctrl
May 15, 2026
Merged

rp2: Correct bit access for rp2_state_machine_init.#18625
dpgeorge merged 1 commit into
micropython:masterfrom
bikeNomad:fix-rp2-shiftctrl

Conversation

@bikeNomad
Copy link
Copy Markdown
Contributor

If you call rp2.StateMachine.init() with pull_thresh=32 it will overwrite the FJOIN_TX bit in the SMx_SHIFTCTRL register. This PR fixes that issue.

Summary

I had a PIO program in which the RXFIFO was not working. I traced it down to asm_pio_override_shiftctrl() shifting the high bit of my pull_thresh argument of 32 into the adjoining bit 30 (FJOIN_TX) of the SMx_SHIFTCTRL register. A threshold of 32 should be encoded as a 0 in bits 29:25 of this register.

This PR uses the bit mask provided as an argument to asm_pio_override_shiftctrl() to ensure that bits outside the field don't get stepped on.

Testing

I tested this with an RP2350 board and a Segger JLINK to ensure that the values in the register were correct.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 31, 2025

Code size report:

Reference:  rp2/rp2_dma: Add support for DMA pacing timers. [5b7a7d8]
Comparison: rp2/rp2_pio: Correct bit access for rp2_state_machine_init. [merge of 7db3204]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@bikeNomad
Copy link
Copy Markdown
Contributor Author

Also included in #18975

Copy link
Copy Markdown
Member

@dpgeorge dpgeorge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix.

If you call `rp2.StateMachine.init()` with `pull_thresh=32` it
will overwrite the FJOIN_TX bit in the SMx_SHIFTCTRL register.
This commit fixes that issue.

Signed-off-by: Ned Konz <ned@metamagix.tech>
@dpgeorge dpgeorge force-pushed the fix-rp2-shiftctrl branch from b683ec2 to 7db3204 Compare May 15, 2026 04:47
@dpgeorge dpgeorge merged commit 7db3204 into micropython:master May 15, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants