![ARTERY AT32F435 Series Reference Manual Download Page 603](http://html1.mh-extra.com/html/artery/at32f435-series/at32f435-series_reference-manual_2977592603.webp)
AT32F435/437
Series Reference Manual
2022.11.11
Page 603
Rev 2.03
Reference clock source
According to IEEE158 standard, the system requires a reference time in a 64-bit format as the current
time record, with the upper 32 bits time information in seconds, and the lower 32 bits time information
in nanoseconds.
The PTP reference clock is used to generate the system time and to capture time stamps. The
frequency of this reference clock must be greater or equal to the resolution of time stamp counter. The
synchronization accuracy between the master node and the slave node is around 100ns.
The time synchronization accuracy depends on the PTP reference clock input period, the frequency
drift of the crystal oscillator and that of the synchronization procedure.
Transmission and reception of frames with PTP feature
When the bit 0 is set in the EMAC_PTPTSCTRL register and the bit 25 is also set in the TDES0 register,
a frame’s SFD is output on the MII, and then a time stamp is captured. The upper 32 bits and the lower
32 bits of the time stamp are stored in the TDES3 and TDES2, respectively so that the time stamp and
transmit status work will be returned to the application all together.
When the bit 0 is set in the EMAC_PTPTSCTRL register and the bit 8 is also set in the
EMAC_PTPTSCTRL register, the EMAC will capture the time stamp of all the received frames on the
MII. The upper 32 bits and the lower 32 bits of the time stamp are stored in the RDES3 and RDES2,
respectively so that the time stamp and receive status work will be returned to the application all together.
System time correction methods
The PTP input reference clock is the system clock SYSCLK, which is used to update the 64-bit time
stamp of the Ethernet frames being transmitted or received. There are two correction methods: coarse
and fine correction.
Coarse correction: the initial value/the offset value is written to the time stamp update registers
(EMAC_PTPTSHUD and EMAC_ PTPTSLUD). When the TI bit is set in the EMAC_PTPTSCTRL
register, an initialization process starts, and system clock counter is updated with the value in the time
stamp update register. If the TU bit is set in the EMAC_PTPTSCTRL register, a correction process
starts, and the time stamp update register value is uses as the offset value, and such offset value is
added or subtracted from the system time.
Fine correction: the slave clock (reference clock) frequency drift with respect to the master clock (as
defined in IEEE1588) is corrected over a period of time. An accumulator sums up the value of the addend
register as shown in Figure 26-15.The pulse generated by the arithmetic carry of the accumulator is
used to increment the system time counter. The addend register value depends on the system clock
frequency. Both the accumulator and the addend are 32-bit registers.