29.01.2015 Views

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

RM0008<br />

Ethernet (ETH): media access control (MAC) with DMA controller<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 <strong>and</strong> 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 <strong>and</strong> 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 <strong>and</strong> 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 comm<strong>and</strong><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 <strong>and</strong> 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) <strong>and</strong> 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 bit 29 in the AFIO_MAPR register. Figure 308 shows the<br />

connection.<br />

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

Ethernet MAC<br />

PTP trigger<br />

ITR1<br />

TIM2<br />

ai15671<br />

Doc ID 13902 Rev 9 877/995

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

Saved successfully!

Ooh no, something went wrong!