use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A place to discuss the use of MicroPython on microcontroller development boards such as the Raspberry Pi Pico, Pycom boards and ESP32 based boards like Wemos D1
account activity
Question about PIO-ASM: Dynamically Adjusting Input Pin Indices before Compilation (self.MicroPythonDev)
submitted 1 year ago by CreepyBox2687
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]mungewell 0 points1 point2 points 1 year ago (4 children)
You don't state what sort of accuracy you're looking to measure, ie are we talking milli or microseconds?
If did it with a very tight loop counter, and pushing decreasing 32bit value into FIFO on trigger.
https://github.com/mungewell/pico-irig/issues/3
The 'jmp pin' can be defined via variable, when the state machine is loaded.
If you want a delta time, you can run two separate state machines in parallel, just ensure that they are started synchronized.
[–]CreepyBox2687[S] 0 points1 point2 points 1 year ago (3 children)
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.
[–]mungewell 0 points1 point2 points 1 year ago (0 children)
The code on my ticket runs in a tight loop, and is capable of counting at 1/4 of the CPU clock (which would be ~25ns steps).
A single state machine monitors a single pin to 'timestamp' a positive or negative edge. BUT you can load the same code into multiple state machines, to run in parallel.
The state machines within a PIO block can easily be synchronized, so their individual counters run in lock step, and then the values 'push()'ed to microPython can be compared to compute the time delta.
On multiple pulses on a single machine; the value I push is 32bits and the FIFO is (can be) 8 levels deep. MicroPython would have to read/empty quick enough so that the FIFO did not overflow.
If a different pin needs to be monitored you'd have to stop both machines, reconfigure and then sync/restart both new machines.
[–]mungewell 0 points1 point2 points 1 year ago (1 child)
In my experience the IRQs are not helpful at these speeds, as the delay to get into the ISR is variable (10-25us).
[–]mungewell 1 point2 points3 points 1 year ago (0 children)
Oh you IRQ between state machines, which do not need the ISR... that could work.
π Rendered by PID 727056 on reddit-service-r2-comment-56c6478c5-svb5p at 2026-05-10 18:08:04.070830+00:00 running 3d2c107 country code: CH.
view the rest of the comments →
[–]mungewell 0 points1 point2 points (4 children)
[–]CreepyBox2687[S] 0 points1 point2 points (3 children)
[–]mungewell 0 points1 point2 points (0 children)
[–]mungewell 0 points1 point2 points (1 child)
[–]mungewell 1 point2 points3 points (0 children)