cancel
Showing results for 
Search instead for 
Did you mean: 

''addend register'' value calculation (for PTP)

Andrew1
Associate II
Posted on November 16, 2015 at 07:49

http://www.st.com/web/en/catalog/tools/FM147/CL1794/SC961/SS1743/PF257871?s_searchtype=keyword

I am confused about ''addend register'' value calculation.

From reference manual:

addend = 2^32 / FreqDivisionRatio;

FreqDivisionRatio = HCLK / 50000000; //50MHz

From PTP demonstraion for STM32F107

(http://www.st.com/web/en/catalog/tools/FM147/CL1794/SC961/SS1743/PF257871?s_searchtype=keyword♯)

Addend = 2^63 / SysClk / Increment

 

ethernetif.h:

...

  /* Examples of subsecond increment and addend values using SysClk = 72 MHz

   

   Addend * Increment = 2^63 / SysClk

    ptp_tick = Increment * 10^9 / 2^31

 

   +-----------+-----------+------------+

   | ptp tick  | Increment | Addend     |

   +-----------+-----------+------------+

   |  119 ns   |   255     | 0x1DF170C7 |

   |  100 ns   |   215     | 0x238391AA |

   |   50 ns   |   107     | 0x475C1B20 |

   |   20 ns   |    43     | 0xB191D856 |

   |   14 ns   |    30     | 0xFE843E9E |

   +-----------+-----------+------------+

  */

&sharpdefine ADJ_FREQ_BASE_ADDEND      0xB191D856

&sharpdefine ADJ_FREQ_BASE_INCREMENT   43

...

Which formula is right?

#ptp-ptpd-stm32f107
1 REPLY 1
Oussema Hajjem_O
Associate III
Posted on November 24, 2015 at 12:11

Hi Andrew,

It's the same formula :),

Just in the reference manual we are fixing the tick accuracy to 20ns 

But in the  PTP demonstration the formula is general for different ptp tick values.

you can check this by replacing the ptp_tick by 20 ns in the equation and you'll find the same result as described in the reference manual.

Best Regards,

LEO