SLAU723A October 2017 – October 2018 MSP432E401Y , MSP432E411Y
The System Time module maintains a 64-bit time and is updated using the MOSC clock source as the PTP clock reference. This time is the source for taking snapshots (timestamps) of the Ethernet frames being transmitted or received. Two methods of updating the system time counter are implemented. The counter can be initialized or corrected using the coarse correction method. In this method, the initial value or the offset value is written to the MAC System Time - Seconds Update (EMACTIMSECU) register along with the MAC System Time - Nanoseconds Update (EMACTIMNANOU) register. For initialization the system time counter is written with the value in these registers, while for system time correction, the offset value is added to or subtracted from the system time.
In the fine correction method, the slave clock frequency drift with respect to the master clock is corrected over a period of time instead of in one clock, as in coarse correction. This helps maintain linear time and does not introduce drastic changes (or a large jitter) in the reference time between PTP Sync message intervals. In this method, an accumulator sums up the contents of the EMACTIMADD register (see Figure 15-11). The arithmetic carry that the accumulator generates is used as a pulse to increment the system time counter. The accumulator and the addend are 32-bit registers. Here, the accumulator acts as a high-precision frequency multiplier or divider.
NOTE
If the Ethernet Controller is configured to use the MII/RMII interface to an external PHY, then the MOSC clock that feeds the PTP reference clock to the System Time Module has a minimum frequency requirement of 5 MHz and a maximum frequency of 25 MHz. For course correction methods, the value of MOSC can be anywhere within this range, but for the fine correction method, a 25-MHz MOSC crystal should be used for the best accuracy. If the Ethernet Controller is configured to use the MII interface connected to the integrated PHY, then the MOSC clock that feeds the PTP reference clock to the System Time Module must be 25 MHz, because it also clocks the integrated PHY module.
Initially, the Ethernet slave clock (from the MOSC) is adjusted with a compensation value (as described in the previous paragraph) which is written to the Timestamp Addend Register (TSAR) field in the EMACTIMADD register. This value is calculated as:
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 232 / 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 232 / 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:
This assumes that the MasterToSlaveDelay is the same for Sync cycles n and n-1.
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.