cancel
Showing results for 
Search instead for 
Did you mean: 

where is the STM32F107xx IEEE 1588 PTPd package?

Dennis Chou
Associate
Posted on February 16, 2018 at 18:55

Where can I download the 

STM32F107xx lwIP stack with IEEE 1588 PTPd support? I have read the application notes AN3102 and AN3411, and the 3411 note appear to indicate there is a PTPd port for this line of processors.

Thanks

Dennis

#stm32f107xx-ptp-ieee-1588
22 REPLIES 22

​Oops, forgot to answer your question about "sub-second update mode". By that, I'm referring to the activating the 'addin' register (ETH_PTPSSIR) which when active (bit 1 TSFCU of ETH_PTPTSCR) sets Fine Update (as opposed to Coarse Update). Coarse Update just adjusts the PTP clock every Sync event (via bit 3 TSSTU of ETH_PTPTSCR) and the PTP clock is 'free running', based on the STM32Fx clock, between updates. In Fine Update mode, the PTP clock is also adjusted every Sync event, but instead of it 'free running' until the next update, the addin register (ETH_PTPTSAR) is adjusted to compensate for differences in frequency between the master and slave clocks. The adjusted addin value (ETH_PTPTSAR) is added to an internal 32 bit PTP accumulator register every uP clock. When that accumulator rolls over, it increments the subsecond PTP register (ETH_PTPTSLR) by a fixed amount (ETH_PTPSSIR).

You can also specify whether one second, the subsecond part of the PTP timer (ETH_PTPTSLR), is represented by 2^31 or  10^9. This is set by bit 9 TSSSR of ETH_PTPTSCR. IEEE-1588 uses (and PTP aware switches) use 10^9, but that requires extra processing to handle in typical code. Because I wasn't directly implementing IEEE-1588, I selected 2^31 mode since it make the math easier. My calculations using t1, t2, t3, and t4 just use the subsecond portion of the PTP timer (since the Sync pulses happen well under a second) and shift it left 1 bit and treat it like a signed value. That shift is done when t1, t2, t3 and t4 are sampled.

Hope that helps.

​ Sorry if this is a repeat. Thought I added a post about missing 'dt' code, but I don't see it. So here it is again:

The 'dt' in the fine adjustment addin calculations (not the dt in the comments about latency) should be added where the ellipsis (...) are:

	uint32_t now = VM_CLOCK;
	int32_t dt = now - ptp_last_update;
	ptp_last_update = now;

where VM_CLOCK is defined to be TIM5->CNT and timer 5 is setup to be 1 MHz (1,000,000 ticks per second). 'dt' is essentially the elapsed time (in ticks, seconds when divided buy 1000000) the currently Sync being process and the previously processed Sync.

hasseb
Associate

I have made a PTP implementation for STM32H7 based on the code from mpthompson. You can find it here: https://github.com/hasseb/stm32h7_atsame70_ptpd