09.12.2012 Views

RM0090: Reference manual - STMicroelectronics

RM0090: Reference manual - STMicroelectronics

RM0090: Reference manual - STMicroelectronics

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Programming steps for system time update in the Coarse correction method<br />

To synchronize or update the system time in one process (coarse correction method),<br />

perform the following steps:<br />

1. Write the offset (positive or negative) in the Time stamp update high and low registers.<br />

2. Set bit 3 (TSSTU) in the Time stamp control register.<br />

3. The value in the Time stamp update registers is added to or subtracted from the system<br />

time when the TSSTU bit is cleared.<br />

Programming steps for system time update in the Fine correction method<br />

To synchronize or update the system time to reduce system-time jitter (fine correction<br />

method), perform the following steps:<br />

1. With the help of the algorithm explained in Section : System Time correction methods,<br />

calculate the rate by which you want to speed up or slow down the system time<br />

increments.<br />

2. Update the time stamp.<br />

3. Wait the time you want the new value of the Addend register to be active. You can do<br />

this by activating the Time stamp trigger interrupt after the system time reaches the<br />

target value.<br />

4. Program the required target time in the Target time high and low registers. Unmask the<br />

Time stamp interrupt by clearing bit 9 in the ETH_MACIMR register.<br />

5. Set Time stamp control register bit 4 (TSARU).<br />

6. When this trigger causes an interrupt, read the ETH_MACSR register.<br />

7. Reprogram the Time stamp addend register with the old value and set ETH_TPTSCR<br />

bit 5 again.<br />

PTP trigger internal connection with TIM2<br />

The MAC provides a trigger interrupt when the system time becomes greater than the target<br />

time. Using an interrupt introduces a known latency plus an uncertainty in the command<br />

execution time.<br />

In order to avoid this uncertainty, a PTP trigger output signal is set high when the system<br />

time is greater than the target time. It is internally connected to the TIM2 input trigger. With<br />

this signal, the input capture feature, the output compare feature and the waveforms of the<br />

timer can be used, triggered by the synchronized PTP system time. No uncertainty is<br />

introduced since the clock of the timer (PCLK1: TIM2 APB1 clock) and PTP reference clock<br />

(HCLK) are synchronous.<br />

This PTP trigger signal is connected to the TIM2 ITR1 input selectable by software. The<br />

connection is enabled through bits 11 and 10 in the TIM2 option register (TIM2_OR).<br />

Figure 344 shows the connection.<br />

Figure 344. PTP trigger output to TIM2 ITR1 connection<br />

Ethernet MAC<br />

PTP trigger<br />

939/1416 Doc ID 018909 Rev 3<br />

ITR1<br />

TIM2<br />

ai15671

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

Saved successfully!

Ooh no, something went wrong!