How to understand update_adjust() function?

If you have a simple question and just want an answer.
Heirun
Member
Posts: 15
Joined: Thu Jun 04, 2015 11:37 am

How to understand update_adjust() function?

Post by Heirun »

AVB_Endpoint_Software(6.1.1) update_adjust function of how to understand it?
User avatar
Thomas
Experienced Member
Posts: 66
Joined: Fri Feb 05, 2010 12:34 pm

Post by Thomas »

update_adjust calculates the ratio between the PTP time and the local time.
The PTP time is determined by the PTP Master that all PTP slaves synchronise to.
The local time is determined by a local oscillator on the PTP slave which will run faster or slower than the global PTP time.

update_adjust calculates the the following values (see gptp.h):
int ptp_adjust; /*!< The adjustment required to convert from
local time to PTP time */
int inv_ptp_adjust; /*!< The adjustment required to convert from
PTP time to local time */

Further References:
AVnu gPTP Tutorial
https://www.eeweb.com/blog/dave_lacey/m ... k-handling

Please note:
AVB 6.1.1 is not recommended for new Designs.
For new Designs we recommend lib_tsn which is used by the following app notes:
AN01032: 100Mbit Ethernet AVB endpoint example using I2S master
AN00202: Gigabit Ethernet AVB endpoint example using I2S master
AN00203: Gigabit Ethernet AVB endpoint example using TDM master
Heirun
Member
Posts: 15
Joined: Thu Jun 04, 2015 11:37 am

Post by Heirun »

Thank you for your answer, I would like to ask these macros like ADJUST_CALC_PREC and PTP_ADJUST_PREC What does it mean? How to understand adjust >> = (ADJUST_CALC_PREC - PTP_ADJUST_PREC)?
User avatar
infiniteimprobability
Verified
XCore Legend
Posts: 1164
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

ADJUST_CALC_PREC and PTP_ADJUST_PREC What does it mean?
Take a look at the source - it's using fixed point maths to make the calculation using 64b signed long longs..

These two defines set where the binary point is for the calculations.

The comment for ADJUST_CALC_PREC eludes to this..

Code: Select all

/* Assume very conservatively that the worst case is that
   the sync messages a .5sec apart. That is 5*10^9ns which can
   be stored in 29 bits. So we have 35 fractional bits to calculate
   with */
#define ADJUST_CALC_PREC 35