09.12.2012 Views

RM0090: Reference manual - STMicroelectronics

RM0090: Reference manual - STMicroelectronics

RM0090: Reference manual - STMicroelectronics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>RM0090</strong> Ethernet (ETH): media access control (MAC) with DMA controller<br />

The algorithm is as follows:<br />

● At time MasterSyncTime (n) the master sends the slave clock a Sync message. The<br />

slave receives this message when its local clock is SlaveClockTime (n) and computes<br />

MasterClockTime (n) as:<br />

MasterClockTime (n) = MasterSyncTime (n) + MasterToSlaveDelay (n)<br />

● The master clock count for current Sync cycle, MasterClockCount (n) is given by:<br />

MasterClockCount (n) = MasterClockTime (n) – MasterClockTime (n – 1) (assuming<br />

that MasterToSlaveDelay is the same for Sync cycles n and n – 1)<br />

● The slave clock count for current Sync cycle, SlaveClockCount (n) is given by:<br />

SlaveClockCount (n) = SlaveClockTime (n) – SlaveClockTime (n – 1)<br />

● The difference between master and slave clock counts for current Sync cycle,<br />

ClockDiffCount (n) is given by:<br />

ClockDiffCount (n) = MasterClockCount (n) – SlaveClockCount (n)<br />

● The frequency-scaling factor for slave clock, FreqScaleFactor (n) is given by:<br />

FreqScaleFactor (n) = (MasterClockCount (n) + ClockDiffCount (n)) /<br />

SlaveClockCount (n)<br />

● The frequency compensation value for Addend register, FreqCompensationValue (n) is<br />

given by:<br />

FreqCompensationValue (n) = FreqScaleFactor (n) × FreqCompensationValue (n – 1)<br />

In theory, this algorithm achieves lock in one Sync cycle; however, it may take several<br />

cycles, due to changing network propagation delays and operating conditions.<br />

This algorithm is self-correcting: if for any reason the slave clock is initially set to a value<br />

from the master that is incorrect, the algorithm corrects it at the cost of more Sync cycles.<br />

Programming steps for system time generation initialization<br />

The time stamping feature can be enabled by setting bit 0 in the Time stamp control register<br />

(ETH__PTPTSCR). However, it is essential to initialize the time stamp counter after this bit<br />

is set to start time stamp operation. The proper sequence is the following:<br />

1. Mask the Time stamp trigger interrupt by setting bit 9 in the MACIMR register.<br />

2. Program Time stamp register bit 0 to enable time stamping.<br />

3. Program the Subsecond increment register based on the PTP clock frequency.<br />

4. If you are using the Fine correction method, program the Time stamp addend register<br />

and set Time stamp control register bit 5 (addend register update).<br />

5. Poll the Time stamp control register until bit 5 is cleared.<br />

6. To select the Fine correction method (if required), program Time stamp control register<br />

bit 1.<br />

7. Program the Time stamp high update and Time stamp low update registers with the<br />

appropriate time value.<br />

8. Set Time stamp control register bit 2 (Time stamp init).<br />

9. The Time stamp counter starts operation as soon as it is initialized with the value<br />

written in the Time stamp update register.<br />

10. Enable the MAC receiver and transmitter for proper time stamping.<br />

Note: If time stamp operation is disabled by clearing bit 0 in the ETH_PTPTSCR register, the<br />

above steps must be repeated to restart the time stamp operation.<br />

Doc ID 018909 Rev 3 938/1416

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!