How do I create a clock output from the gPTP time on an AVB Topic is solved

If you have a simple question and just want an answer.
AndreasL
Newbie
Posts: 1
Joined: Fri Oct 17, 2014 11:55 am

How do I create a clock output from the gPTP time on an AVB

Post by AndreasL »

To measure synchronization between a PTP master and a PTP slave usually you use a 1PPS (1 pulse per second) signal which is then feeded into a testsystem.

The signal must be derived from the gPTP clock and toggle a hardware pin which then can be used to measure.

How could I achieve that on a XMOS device running the AVB reference design?



View Solution
User avatar
Thomas
Experienced Member
Posts: 66
Joined: Fri Feb 05, 2010 12:34 pm

Post by Thomas »

The AVB Endpoint Software contains a task gptp_test_clock which is dedicated to generate a HW clock from the gPTP time.
This task can be instantiated on a core in the par { } block of the application main() 
The HW clock can be observed with a scope on the chosen GPIO pin and used to check the quality of the gPTP time synchronisation between multiple AVB Endpoints.
 
Here are the code changes to achieve this for AVB 5.2.1 release and AVB 6.0.4 release respectively:
 
All changes are made in the main.xc file.
 
Common changes:
- Instantiate an output port:
on tile[0]: port test_clock_port = XS1_PORT_4C;


- Define the clock period in ns. E.g. for a 1 PPS (1Hz) clock signal:
#define gPTP_HW_CLK_PERIOD 1E9


 
AVB 5.2.1 specific:
An additional channel is needed to connect gptp_test_clock (a PTP client) to the PTP server.
1. Increase the c_ptp array by one channel item:
  // PTP channels

  chan c_ptp[2 + AVB_DEMO_ENABLE_TALKER];


 
2. In the media_clock_server parameter increase the number of c_ptp channel array items
                                   2 + AVB_DEMO_ENABLE_TALKER,
 
And then add this to the task list in par {}:
    // Generate HW clock from gPTP time

    on tile[0]: ptp_output_test_clock(c_ptp[2],

                        test_clock_port,

                        gPTP_HW_CLK_PERIOD);


 


 
AVB 6.0.4 specifc:
An additional channel is needed to connect gptp_test_clock (a PTP client) to the PTP server.
All you need to do to achieve this is add a new value to this enum before NUM_PTP_CHANS
Let's call it PTP_TO_HW_CLK
The enum should now look like this:
enum ptp_chans {

  PTP_TO_AVB_MANAGER = 0,

#if AVB_DEMO_ENABLE_TALKER

  PTP_TO_TALKER,

#endif

  PTP_TO_1722_1,

  PTP_TO_HW_CLK,

  NUM_PTP_CHANS

};



 
enums are useful for writing extensible code. NUM_PTP_CHANS is always calculated correctly based on the number of values that come before it.
 
And then add this to the task list in par {}:
    on tile[0]: ptp_output_test_clock(c_ptp[PTP_TO_HW_CLK],

                        test_clock_port,

                        gPTP_HW_CLK_PERIOD);