Precise Synchronization of multiple PIO Blocks #16387
-
Previously I have been using I can allocate a GPIO pin and use
This gets me within ~5.15us delta between PIO Block-1 and Block-2, which I assume is the CPU time taken to do the 2 writes to memory... Does anyone have a solution to tweak out that last 5us, so they are EXACTLY aligned? Background: My app is looking at timing, referenced to GPS 1PPS and 10MHz clock. I want to produce an encoded clock signal which is accurate as possible (ie not delayed even by 5us) . |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Haven't tested it, but this should sync'em down to a few ns. #!/micropython
# -*- coding: UTF-8 -*-
# vim: fileencoding=utf-8: ts=4: sw=4: expandtab:
@micropython.asm_thumb
def syncem(r0, r1):
mov(r2, 0xf)
mov(r3, 8)
lsl(r2, r3)
str(r2, [r0, 0])
str(r2, [r1, 0])
syncem(0x50200000, 0x50300000) |
Beta Was this translation helpful? Give feedback.
-
@GitHubsSilverBullet I re-wrote the routine a bit, using a previous posting:
My reason was that I wanted to this to be called as the interrupt handler, as it would be called as quickly as possible after the trigger edge was first detected... but that would not be able to present the R0, R1 values. Hence they need to be hard coded.
[EDIT] I realized that I was starting the WRONG statemachine and triggering a error in a different part of the system... |
Beta Was this translation helpful? Give feedback.
Haven't tested it, but this should sync'em down to a few ns.