GD32F20x User Manual
806
Assuming the accuracy of the system time update circuit required to achieve 20ns, which
means the frequency of update is 50MHz. If the reference clock of HCLK is 75MHz, the
frequency ratio is calculated as 75/50, result is 1.5. Hence, the addend (TMSA bit in
ENET_PTP_TSADDEND register) value to be set is 2
32
/1.5, which is equal to 0xAAAA AAAA.
If the reference clock frequency drifts lower, for example, down to 65MHz, the frequency ratio
changes to 65/50=1.3, the value to be set in the addend register is 2
32
/1.30 = 0xC4EC 4EC4.
If the reference clock drift higher, for example, up to 85MHz, the value addend register must
be 0xA000 0000. Initially, the slave clock frequency is set to Clock Addend Value (0) in the
addend register. This value is calculated as above. In addition to configuring the addend
counter, application also needs to set subsecond increment register to ensure to achieve the
precision of 20ns. The value of the register is to update values of timestamp low 32-bit register
after accumulator register overflow. Because the timestamp low register (bit 0 to 30)
represents the subsecond value of system time, the precision is 10
9
ns/2
31
=0.46ns. So in order
to make the system time accuracy to 20ns, sub second increment register value should be
set to 20/0.46 = 0d43.
Note:
The algorithm described below based on constant delay transferred between master
and slave devices (Master-to-Slave-Delay). Synchronous frequency ratio will be confirmed by
the algorithm after a few Sync cycles.
Algorithm is as follows:
Define the master sends a SYNC message to slave time: MSYNCT (n).
Define the slave local time SLOCALT (n).
Define the master local time MLOCALT (n).
Calculation: MLOCALT (n) = MSYNCT (n) + Master-to-Slave-Delay (n)
Define the master clock count number between two SYNC message sent:
MCLOCKC(n)
Calculation: MCLOCKC (n) = MLOCALT (n)
– MLOCALT (n-1)
Define the slave clock count number between two received SYNC messages: SCLOCKC
(n)
Calculation: SCLOCKC (n) = SLOCALT (n) - SLOCALT (n-1)
Define the difference between these two count numbers: DIFFCC (n)
Calculation: DIFFCC (n) = MCLOCKC (n) - SCLOCKC (n)
Define the slave clock frequency-adjusting factor: SCFAF (n)
Calculation: SCFAF (n) = (MCLOCKC (n) + DIFFCC (n)) / SCLOCKC (n)
Define the Clock Addend Value for addend register: Clock Addend Value (n)
Clock Addend Value (n) = SCFAF (n) * Clock Addend Value (n-1)
Note
: During the actual operation, application may need more than once SYNC message
between master and slave to lock.
System time initialization procedure
Setting TMSEN bit in ENET_PTP_TSCTL register to 1, timestamp function is enabled. Each
Содержание GD32F20 Series
Страница 1: ...GigaDevice Semiconductor Inc GD32F20x ARM Cortex M3 32 bit MCU User Manual Revision 2 2 Oct 2019 ...
Страница 191: ...GD32F20x User Manual 191 Bits Fields Descriptions 31 0 TRNDATA 31 0 32 Bit Random data ...
Страница 290: ...GD32F20x User Manual 290 conversion is ongoing ...
Страница 325: ...GD32F20x User Manual 325 15 0 ALRM 15 0 RTC alarm value low ...
Страница 385: ...GD32F20x User Manual 385 ...
Страница 523: ...GD32F20x User Manual 523 clears AERR bit by writing 0 to it ...