Discussion:
[Linuxptp-devel] Synchronize PWM to CPTS internal counter
David Cemin
2016-11-30 20:59:57 UTC
Permalink
Hi Kim,


On this thread (https://www.mail-archive.com/linuxptp-***@lists.sourceforge.net/msg01033.html)
you wrote this
We implemented PPS output signal through AM335x Dual-Mode Timer >running in
the PWM mode with SCLK frequency.
This is more accurate than software GPIO output because the CPTS >on the
AM335x
can generate hardware timestamp event on the rising edge of the >DMTimer,
making it possible to synchronize PPS with the CPTS internal clock <counter.
Can you (or someone else on this list) give more details on how did
you achieve this? Im not sure sure you actually got the pps output
sync to PTP on this approach. How did you connect the CPTS to the PWM
?


Thanks


--

David
Yursen Kim
2016-12-02 06:43:56 UTC
Permalink
Greetings! Thank you for your interest.

The basic idea is to adjust PWM output depending on the captured CPTS
timestamps, thus eliminating any software latencies.

1. Start DM timer free-running as a 1 sec period PWM.
2. Enable generation of CPTS hardware timestamp events on this timer.
3. On each CPTS HW_TS event, calculate the offset and change TLDR value.

One person (I am not sure I can tell his name) did some improvements to
this:

1. He starts PWM close to nearest second (from HW_TS_PUSH event), and uses
a simple PI controller for TLDR.
2. He also enables the actual PWM hardware output after a first few
adjustment pulses.

Best regards,
Kim Yursen
Post by David Cemin
Hi Kim,
We implemented PPS output signal through AM335x Dual-Mode Timer >running in
the PWM mode with SCLK frequency.
This is more accurate than software GPIO output because the CPTS >on the
AM335x
can generate hardware timestamp event on the rising edge of the >DMTimer,
making it possible to synchronize PPS with the CPTS internal clock <counter.
Can you (or someone else on this list) give more details on how did you achieve this? Im not sure sure you actually got the pps output sync to PTP on this approach. How did you connect the CPTS to the PWM ?
Thanks
--
David
Delio Brignoli
2016-12-02 09:10:06 UTC
Permalink
Hello David,

We use a different SoC equipped with CPTS and we do not generate a PPS signal but we do something which I believe can be adapted to obtain a PPS signal. We leave the CPTS clock free-running and use it as gPTP local clock timebase using linuxptp. We also use DMTimer to trigger CPTS hardware timestamp events and adjust the clock source for the relevant DMTimer using said hardware timestamp events and localclock <—-> gPTP mapping calculated by linuxptp.

HTH
--
Delio Brignoli
AudioScience Inc
Post by David Cemin
Hi Kim,
We implemented PPS output signal through AM335x Dual-Mode Timer >running in
the PWM mode with SCLK frequency.
This is more accurate than software GPIO output because the CPTS >on the
AM335x
can generate hardware timestamp event on the rising edge of the >DMTimer,
making it possible to synchronize PPS with the CPTS internal clock <counter.
Can you (or someone else on this list) give more details on how did you achieve this? Im not sure sure you actually got the pps output sync to PTP on this approach. How did you connect the CPTS to the PWM ?
Thanks
--
David
------------------------------------------------------------------------------
_______________________________________________
Linuxptp-devel mailing list
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
David Cemin
2016-12-03 19:22:47 UTC
Permalink
Thank you Kim an Delio,

I think that this is quite easy to implement and i will give it a try.

This will for find for 1Hz pulses, but what if i wanted to generate higher
frequencies (i.e. 10kHz+) ?

on the CPTS section where it explains about the TS_PUSH events coming from
the timers, its written this:
" Hardware time stamps are intended to be an extremely low frequency
signals, such that the event FIFO does not overrun. Software must keep up
with the event FIFO and ensure that there is no overrun, or events will be
lost."

So this approach might not be adequate for this purpose (higher
frequencies). I was thinking in maybe using one of this timers (or a pwm)
and sync and synchronize it to ptp using phc2sys. Do you see any problem on
this approach for higher frequencies or do you have any other ideas that
you wouldnt mind sharing ?

Thanks
Post by Delio Brignoli
Hello David,
We use a different SoC equipped with CPTS and we do not generate a PPS
signal but we do something which I believe can be adapted to obtain a PPS
signal. We leave the CPTS clock free-running and use it as gPTP local clock
timebase using linuxptp. We also use DMTimer to trigger CPTS hardware
timestamp events and adjust the clock source for the relevant DMTimer using
said hardware timestamp events and localclock <—-> gPTP mapping calculated
by linuxptp.
HTH
--
Delio Brignoli
AudioScience Inc
Post by David Cemin
Hi Kim,
sourceforge.net/msg01033.html) you wrote this
Post by David Cemin
We implemented PPS output signal through AM335x Dual-Mode Timer
running in
the PWM mode with SCLK frequency.
This is more accurate than software GPIO output because the CPTS >on the
AM335x
can generate hardware timestamp event on the rising edge of the
DMTimer,
making it possible to synchronize PPS with the CPTS internal clock
<counter.
Post by David Cemin
Can you (or someone else on this list) give more details on how did you
achieve this? Im not sure sure you actually got the pps output sync to PTP
on this approach. How did you connect the CPTS to the PWM ?
Post by David Cemin
Thanks
--
David
------------------------------------------------------------
------------------
Post by David Cemin
_______________________________________________
Linuxptp-devel mailing list
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
--
*+1 (343) 777-1735* David Cemin http://coveloz.com


<http://coveloz.com/>
Andrew Symington
2016-12-03 20:46:20 UTC
Permalink
Substantial work has been put in by my old research group at UCLA to expose
the am335x internal timers as PTP clocks. The general thrust of the project
is to expose Quality of Time (QoT) to the application layer, allowing the
OS to balance resources (sync) with demand (application time requirements).

If I recall correctly, we were able to generate a PWM signal from a
hardware timer with a known rising edge, which we internally used to
trigger a CPTS event. In so doing we synchronized the am335x clocks to the
PTP clock. Presumably a similar method can be used for PPS.

Here's a kernel module to expose the am335x clocks as PTP clocks:

https://bitbucket.org/rose-line/qot-stack/src/59b4c96dd55c6470b91ae2456460f52973483fa4/src/modules/qot_am335x/qot_am335x.c?at=thorn16_refactor&fileviewer=file-view-default

Andrew
Post by David Cemin
Thank you Kim an Delio,
I think that this is quite easy to implement and i will give it a try.
This will for find for 1Hz pulses, but what if i wanted to generate higher
frequencies (i.e. 10kHz+) ?
on the CPTS section where it explains about the TS_PUSH events coming from
" Hardware time stamps are intended to be an extremely low frequency
signals, such that the event FIFO does not overrun. Software must keep up
with the event FIFO and ensure that there is no overrun, or events will be
lost."
So this approach might not be adequate for this purpose (higher
frequencies). I was thinking in maybe using one of this timers (or a pwm)
and sync and synchronize it to ptp using phc2sys. Do you see any problem on
this approach for higher frequencies or do you have any other ideas that
you wouldnt mind sharing ?
Thanks
Post by Delio Brignoli
Hello David,
We use a different SoC equipped with CPTS and we do not generate a PPS
signal but we do something which I believe can be adapted to obtain a PPS
signal. We leave the CPTS clock free-running and use it as gPTP local clock
timebase using linuxptp. We also use DMTimer to trigger CPTS hardware
timestamp events and adjust the clock source for the relevant DMTimer using
said hardware timestamp events and localclock <—-> gPTP mapping calculated
by linuxptp.
HTH
--
Delio Brignoli
AudioScience Inc
Post by David Cemin
Hi Kim,
On this thread (https://www.mail-archive.com/
We implemented PPS output signal through AM335x Dual-Mode Timer
running in
the PWM mode with SCLK frequency.
This is more accurate than software GPIO output because the CPTS >on
the
Post by David Cemin
AM335x
can generate hardware timestamp event on the rising edge of the
DMTimer,
making it possible to synchronize PPS with the CPTS internal clock
<counter.
Post by David Cemin
Can you (or someone else on this list) give more details on how did you
achieve this? Im not sure sure you actually got the pps output sync to PTP
on this approach. How did you connect the CPTS to the PWM ?
Post by David Cemin
Thanks
--
David
------------------------------------------------------------
------------------
Post by David Cemin
_______________________________________________
Linuxptp-devel mailing list
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
--
*+1 (343) 777-1735 <(343)%20777-1735>* David Cemin http://coveloz.com
<http://coveloz.com/>
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
Loading...