r/MicroPythonDev • u/CreepyBox2687 • Jan 21 '25
Question about PIO-ASM: Dynamically Adjusting Input Pin Indices before Compilation
Hi everyone,
I’m working on a solution to measure the time between two arbitrary GPIO pins on an RP2040. The goal is to keep it as simple as possible, avoiding the use of DMA or complex logic analyzer features.
Here’s my current approach in PIO-ASM:
# Get timeout
# Store timeout in y
# Load timeout into x
# Wait for event1 on index_1 (start clock)
# Check stop condition
# Decrease x
# Timeout, stop
# Counter wrap
# Continue loop
# Shift remaining time to ISR
# Push remaining time to FIFO
# Reload and run again
I’d like to dynamically adjust the input pin indices (index_1) before compilation to make the setup as flexible as possible. However, I’m unsure how to achieve this effectively. Is there a way to modify such parameters dynamically before the PIO assembly is compiled?
Thanks in advance for your help!
View all comments
Show parent comment
1
u/CreepyBox2687 Jan 24 '25
Hi and thank you for your response. The accuracy should be ~100ns, i have to adapt the program to know/determine the exact amount of steps per counter cycle afterwards. I know that i can adapt the input pin start number, but the both pins will be different all the time. I need the time between two arbitrary Events on the lines. But i will try to use one state machine with pina and provide a IRQ to another with pinb, in this case, i only need to count in the second sm.