The 8 MHz quartz crystal measures as expected at a buffered node, but one hardware-timestamped test frame per second shows that the STM32F107 gains roughly a millisecond per minute. Resetting the seconds value only returns that error trace to its starting point. On the bench, make a known change to the timestamp addend and measure how the slope responds. This separates addend errors and wrong clock ratios from a constant delay in the test link.
Trace the clock that feeds the timestamp counter
ST's RM0008 describes HCLK as the PTP system time reference in this Ethernet MAC. The MAC takes snapshots of that time as frames pass through the MII. In the example, an 8 MHz quartz crystal drives a nine-times main PLL with no further AHB division, giving HCLK at 72 MHz. The board can have a separate PHY clock. A working link with no dropped packets does not establish the clock ratio in the timestamp path. Read the selected system clock source and dividers, then use a configurable clock output or a known divided test point to verify the actual ratio. A buffered point lets you avoid probing a crystal oscillator pin directly.
In Fine Update mode, hardware adds the addend to a 32-bit accumulator on each HCLK cycle. A carry from that accumulator advances the subseconds counter by a fixed increment. Coarse correction works differently. With HCLK and the increment held constant, the mean timestamp rate is proportional to the addend. Write the addend, set the update bit as described in the manual, and wait for hardware to clear it. Reading back the value confirms the register write, while the measured slope confirms that the counter acts on the value.
Run a blind comparison at two addend values
Use a subsecond increment of 64 binary units. With 2³¹ units in a full second, the counter advances at 72,000,000 × 64 × addend ÷ 2⁶³ seconds per second. The nearest nominal integer addend is 2,001,599,834, or 0x774DFD5A. Raise that by 32,768 with everything else held constant. The rate increases by about 16.371 ppm and gains about 1.965 ms over 120 seconds. This is a deliberately measurable test adjustment. Reversing the step should reverse the slope change.
Send equally spaced test frames from an independent timebase. Pair the reference and local hardware records by frame ID. A fixed, direct link with constant frame format, line rate, and direction works well. Use the hardware timestamp instead of the software interrupt time. Fit the timestamp difference against reference time in two windows of identical length. Pause the firmware that would otherwise adjust the addend or step time. Start each window after the update bit clears, and discard a frame that straddles that edge.
Let the error curve decide what to check
The two windows can start at different offsets. Constant path delay drops out of the slope comparison if the link stays fixed. The original slope should also return when you restore the original addend. If a step in either direction has no measurable effect, check the Fine Update selection, whether hardware clears the update bit, and whether the timestamp comes from the current port descriptor. A new hexadecimal value in the log is less informative than a corresponding change in rate.
If the addend changes the slope as predicted but the nominal setting still gains time, recalculate the combination of HCLK and the subsecond increment. The relative frequency offset measured on the buffered 8 MHz crystal path carries through ideal frequency multiplication. If the buffered reading is 2 ppm high and the counter still gains at 14 ppm, about 12 ppm remains to be explained. Check the loaded register values, external reference error, and time-unit conversion before widening the crystal tolerance.
Another error pattern is a discontinuity each time the subsecond field wraps. Keep the raw seconds and subseconds next to the converted timestamp. Check for a binary field being treated as decimal nanoseconds or for the seconds from one frame being paired with another frame's subseconds. Send frames across a seconds boundary and compare short windows on both sides. If only the conversion produces the jump, fix the interpretation.
A timer on the same board can share the wrong clock ratio, making an internally triggered test appear correct. Substitute a generator with its own timebase and compare the buffered clock independently. Document which transmit or receive timestamp is used and whether a switch is in the path. Pair by frame ID so a missing frame cannot silently shift the entire record.
Record the conditions and the outcome
Keep the firmware version, crystal lot, HCLK, increment, addend values, update-bit state, and fit windows in the production record. Attach the independent frequency reading, the slope difference, the returned nominal slope, and the raw timestamp continuity check. Close to a limit, repeat with a reverse step and account for reference and fit uncertainty. A late packet or host clock refresh alone does not establish a crystal fault.
If the board is also being considered for a same-frequency active clock, verify bypass mode, logic levels, and startup separately. Compare it under the same HCLK and timestamp settings. If the reference frequency and the two slopes match the prediction, focus on register loading or timestamp handling. Investigate crystal stability or load with the original and replacement parts only if the remaining slope is consistent with an independently measured offset on the 8 MHz quartz crystal.
