Description
This feature would enable many amateurs and professionals to leverage the power of processor peripherals for precise microsecond level timing applications, such as measurement, where Circuitpython's inherent time resolution of near 1 millisecond is insufficient.
Use of IRQs would not be needed (to the best of my knowledge). The trigger would merely be a state change of a register or more specifically, particular bits of a register.
Example Need:
A current project, a precise ultrasonic range finder, uses the RP2040. As sound travels at 343 meters per second or 343 micrometers per microsecond, microsecond timing is needed "even" to acquire near millimeter precision.
The current timing in Circuitpython is about 1 millisecond. However, with peripherals like the DMA and PIO many timing issues can be improved.
One such timing issue was improved for the Circuitpython 8.0.0 release throught the feature analogbufio. This new library addition to Circuitpython allows for fast ADC read into memory at speeds of up to 2.0 microseconds per ADC conversion.
Another feature of the rp2040 and pioasm has been to generate a finite number of 'perfect' squarewaves at precisely 40KHZ or 25 microsecond cycle width. Using the PIO assembly one can also institute a desired delay before the pulse with extreme precision. Call the function 'Pulse8'.
While either are very precise independently, the exact time between invocation and actual execution is in the implementation details (overhead) of Circuitpython.
Attempts to measure the overhead for both 'analogbufio.readinto()' and the call to 'Pulse8()' have been difficult. By making use of the rp2pio.background_write() one can kick off the pulse then quickly (well ... quicker anyway) call analogbufio.readinto().
Many experiments are made without the transducers by merely connecting the digital pulse out to the ADC0 input. This is merely an electronic kludge but it works for measuring and one can assume nearly zero delay from the transmit pin to the ADC0 pin.
Because the two actions are inherently independent (from a circuitpython view) the best timing offset estimation is around 800 microseconds plus or minus 100 microseconds (estd).
Solution:
Using an RP2PIO State Machine, one might SET (active timing) or GET (passive timing) specified triggers where the PIO timing is extremely precise.
The result of this enhancement to Circuitpython may stretch across various other microcontrollers extending the capability of Circuitpython. This feature will further reduce the need to write complex applications in C using detailed hardware knowledge. This feature will also eliminate the need to electrically cross connect IO pins usually requiring external adder circuits.