On Thu, Nov 12, 2015 at 2:08 AM, Richard Cochran <[email protected]>
wrote:

> On Wed, Nov 11, 2015 at 02:37:28PM -0600, Bassam Alsanie wrote:
> > I need to make my homework first.
> > After looking into the function adjtimes things made more sense to me.
> > The missing piece in my understand for now that the timex.freq unit is in
> > ppm and its long, so no fractions for the ppb.
>
> [Sigh]
>
> No, as I already told you off-list, the frequency is in ppm with a 16
> bit fractional field.
>
> That means:
>
>         0x00010000 = 1 ppm
>         0x00018000 = 1.5 ppm
>         0x00014000 = 1.25 ppm
>
> See?
>
>
>  Yes, that make sense. OK then, in the function
clockadj_set_freq(struct tClockid clkidStrut, double freq);
we convert 'freq' to ppm like this: (I am still not sure what freq really
mean as input into this function)
tx.freq = (long) (freq * 65.536);

and my custom clock I can compute the frequency shift as the following:

    __u16 fraction = ((__u64) tx.freq & 0x0000ffff);
    __u16 integer  = (__u64) tx.freq >> 16;
__u64 requestedPpb = (integer * 1000) + fraction;

__s64 freqShiftInHz = (__u64) (currentFreq * requestedPpb) / kPpb;

where, currentFreq is the current centrer frequency of the clock (mine is
around 100 MHz)


Thoughts?

Thank you
Bassam,
------------------------------------------------------------------------------
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to