Get Wall-Time From PRU

I am reading values from the ADC using the PRU. I need to timestamp the values with sub-millisecond accuracy, but I’m not sure how to get the clock time from the PRU. My BBB system clock is updated with a GPS, so pulling time from that would be ideal. Is this possible? If so, how?

Regards,
Istvan.

To get sub-millisecond accuracy, you'll need a good timer running that the PRU can read. The timer will have to have good jitter characteristics (within the sub-millisecond requirement), and will have to be synchronized to wall clock time somehow.

I haven't looked at the ADC's sampling time, but you'll probably have to account for that in your quest for accuracy.

Many GPS modules have a 1 pulse-per-second signal that's supposed to trigger on the second. You might be able to set up a 1000 Hz (or more) PLL against that to update the timer, and read that from the PRU when you read your ADC sample. You'll have to evaluate the latencies involved in reading the timer register, and reading the ADC (how long from when the voltage was sampled until the ADC result is ready). Once you have those values, you can subtract them from the time you read. You probably don't have to do that math on the PRU, if you don't need the result right away. The timestamp could still be correct, just might take a while to compute (relative to the accuracy you're looking for).

I once saw an article in Circuit Cellar about making a very accurate timer using the GPS PPS signal. You might want a hardware PLL to feed the timer clock input (I'm assuming there's one on the BBB, don't know for sure). You might also be able to get a software PLL working on one of the PRU cores, depending on how much else that core needs to do.

with sub-millisecond accuracy.

PRU has profiling register, tick counter. It could be used for precise time stamping.

@Istvan.

when your timing is equidistant, you could configure the ADC subsystem to hardware trigger the measurements by an external trigger (timer-[4-7])… Or use the timer integrated in the PRU-IEP to trigger an ADC measurement by softeware. For non-equidistant timings you could use the IEP timer as a counter (200 MHz).