PIO 1us Timestamp - solution with DMA, FIFO and TIMELR/TIMEHR registers #18716
-
|
About a year ago I was asking about time-stamping when a PIO goes high/low, and I've now got a solution using DMA to copy TIMELR/TIMEHR registers into a FIFO, and then another PIO copies TX FIFO directly back to RX FIFO. App can then (leisurely) grab the precised timestamps from FIFO. Example code: So with a GPS providing a 1PPS pulse, I get a nice count of us values. The eagle-eyed among us will have spotted that the last value is 1us 'different' from expected, this is down to my XTAL not being perfect on this board - but it's pretty damn good. A longer (over night) run gives: So between second '160' and second '39609' (delta 39449s) the fractional portion went from '944299' to '945460' (delta 1161us), meaning my 12MHz XTAL is actually "(39500.00161 / 39500) * 12" = 12.000000353MHz (ie off by about 29ppb)... pretty sure I replace the XTAL with TCXO on that board ;-) Note: that's average... the log shows frequency fluctuations up to that point. After that point in the log... something else happened.
Unfortunately this code doesn't work on the RP2350 at the moment, LED alternates with PIO input but no timestamps are printed. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
|
The 'wonky' bit is very close to the end of the log, perhaps I disturbed the cables when I came in and shut the log down. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
rp2350 uses a different timer base value.... Yes, that's a stock XTAL... |
Beta Was this translation helpful? Give feedback.
-
|
Wrapping this up with a script to configure GPS (Mosaic X in my case), trigger timestamps from the PPS signal, whilst monitoring the UART for GGA/ZDA messages. Timestamp output tied to/references GPS message time. |
Beta Was this translation helpful? Give feedback.



Wrapping this up with a script to configure GPS (Mosaic X in my case), trigger timestamps from the PPS signal, whilst monitoring the UART for GGA/ZDA messages.
gps_dma_timestamp.py.txt
Timestamp output tied to/references GPS message time.