Functional Description
918
SLAU723A – October 2017 – Revised October 2018
Copyright © 2017–2018, Texas Instruments Incorporated
Ethernet Controller
The System Time Module requires a 20-MHz PTP reference clock frequency to achieve 50-ns accuracy in
the fine correction method. An addend must be written to the Ethernet MAC Time Stamp Addend
(EMACTIMADD) register, offset 0x718 to achieve timing synchronization. If the MOSC clock source is
25 MHz, the frequency division ratio (FreqDivisionRatio) of the two is calculated as 25 MHz / 20 MHz =
1.25. Hence, the default addend value to be set in the register is 2
32
/ 1.25 or 0xCCCC.CCD0. If the
reference clock drifts lower, to 24 MHz for example, the ratio is 24 / 20, or 1.2 and the value to set in the
addend register is 2
32
/ 1.20, or 0xDFF1.65D2. The software must calculate the drift in frequency based on
the Sync messages and update the EMACTIMADD register, at offset 0x718, accordingly.
If the master to slave delay is initially assumed to be the same for consecutive Sync messages, then the
following steps can be used to calculate a new TSAR value. The following algorithm calculates the precise
mater to slave delay value to allow for re-synchronization with the master using the new value:
1. At time MasterSyncTime
n
the master sends the slave clock a Sync message. The slave receives this
message when its local clock is SlaveClockTime
n
and computes MasterClockTime
n
as:
MasterClockTime
n
= MasterSyncTime
n
+ MasterToSlaveDelay
n
(51)
2. The master clock count, MasterClockCount
n
, for the current Sync cycle is given by:
MasterClockCount
n
= MasterClockTime
n
– MasterClockTime
n-1
(52)
This assumes that the MasterToSlaveDelay is the same for Sync cycles n and n-1.
3. The slave clock count for current Sync cycle, SlaveClockCount
n
is given by:
SlaveClockCount
n
= SlaveClockTime
n
– SlaveClockTime
n-1
(53)
4. The difference between the master and slave clock counts for the current Sync cycle, ClockDiffCount
n
,
is given by:
ClockDiffCount
n
= MasterClockCount
n
– SlaveClockCount
n
(54)
5. The frequency-scaling factor for the slave clock, FreqScaleFactor
n
is given by:
FreqScaleFactor
n
= (MasterClockCount
n
+ ClockDiffCount
n
) / SlaveClockCount
n
(55)
6. The frequency compensation value, FreqCompensationValue, to be written in the TSAR field of the
EMACTIMADD register is:
FreqCompensationValue
n
= FreqScaleFactor
n
× FreqCompensationValue
n-1
(56)
In theory, this algorithm achieves lock in one Sync cycle; however, it may take several cycles, because of
changing network propagation delays and operating conditions. This algorithm is self-correcting: if for any
reason the slave clock is initially set to a value from the master that is incorrect, the algorithm corrects it at
the cost of more Sync cycles.
15.3.6.2 Transmit Timestamping
The MAC captures a timestamp when the Start Frame Delimiter (SFD) of a frame is sent. The transmit
frames are marked to indicate whether a timestamp should be captured for that frame and written to the
extended transmit descriptors that support timestamping. The MAC returns the timestamp automatically to
the corresponding transmit descriptor, thus connecting the timestamp with the specific PTP frame. The 64-
bit timestamp information is written to the TDES6 and TDES7 fields.
15.3.6.3 Receive Timestamping
The MAC captures the timestamp of all received frames. The MAC does not process the received frames
to identify the PTP frames in default timestamping mode (when Advanced Timestamp is disabled). The
MAC gives the timestamp and the corresponding status to the TX/RX Controller along with the EOF data.
The TX/RX Controller validates and indicates the availability of the timestamp so that the DMA can return
the timestamp to the corresponding receive descriptor. The 64-bit timestamp information is written to the
RDES6 and RDES7 fields. The timestamp is written only to the receive descriptor for which the Last
Descriptor status field has been set to 1 (the EOF marker). When the timestamp is not available (for
example, because of an RX FIFO overflow), an all '1s' pattern is written to the descriptors (RDES6 and
RDES7), indicating that the timestamp is not correct. If timestamping is disabled, the DMA does not alter
RDES6 or RDES7. RDES0[7] indicates whether the timestamp is updated in RDES6 and RDES7.