Specialist Supplier of Crystals & Frequency Control Componentssales@mecxtal.com.cn0755-26500570
MERLIN home / Rednote / System Validation and Replacement

Why do MCP2518FD timestamps run at half the expected scale with the same 40 MHz crystal?

An industrial network board uses a 40 MHz passive crystal for its MCP2518FD. Two revisions both show 10 MHz at the clock test point and pass frame transfers at their configured CAN FD rates. The new revision reports half the intervals shown by an external analyzer. Reading one clock pin can miss a separate branch inside the controller. Compare raw timestamp counts before investigating how the host converts them.

Trace CLKO and the timestamp back to their own dividers

Microchip's oscillator diagram branches after the source selection. SCLKDIV generates SYSCLK for the controller and internal logic. CLKODIV supplies CLKO. With a 40 MHz passive crystal selected directly, the PLL off, and CLKO divided by four, the pin reads 10 MHz. Changing the system branch from divide-by-one to divide-by-two shifts SYSCLK from 40 to 20 MHz while CLKO can still read 10 MHz. The pin verifies its own branch.

The timestamp time base counts multiples of SYSCLK. TBCPRE of zero uses every system clock. TBCPRE of 39 uses 40 clocks. That gives one microsecond per count at 40 MHz but two at 20 MHz. If the host still reports every count as one microsecond, a real two-millisecond interval appears to be one millisecond. Changing CLKO's divisor does not correct that conversion.

For a one-microsecond count at 20 MHz, set TBCPRE to 19, representing 20 system clocks. Check CAN bit timing and the other interface settings independently rather than changing SYSCLK simply to recover the old timestamp scale. Record the 40 MHz passive crystal, PLL selection, both clock dividers, and the timer prescaler in the handoff.

Match the timestamp event as well as its unit

Microchip provides separate timestamp enables for receive FIFOs and the transmit event FIFO. Timestamp controls choose when within the frame the value is recorded, and TSRES further affects the beginning-of-frame case for CAN FD. Compare like events with the external analyzer. A test generator can send identical frames at known intervals so both measurements can use a defined frame marker. Comparing frame start on one instrument with frame end on the other can introduce a size-dependent offset.

The 32-bit count wraps after approximately 4,294.967 seconds, or 71.58 minutes, at one microsecond per count. A short interval within a single counter run can be computed modulo two to the 32nd power across one wrap. Clearing TBCEN stops and resets the counter. Mark that reset as a new epoch so that software does not interpret it as ordinary wraparound.

Collect counts, measured intervals, and application results

Send frames at a fixed interval and retain raw timestamps. A two-millisecond separation gives approximately 2,000 counts at one microsecond per count and 1,000 at two. Observe the same events with an external instrument and compare the displayed value. If raw counts halve, read back the SYSCLK path and TBCPRE. If counts stay correct and only the interface changes, inspect cached conversion parameters or the data export.

Compare both normal startup and the first records after reconfiguration. If firmware changes the timestamp unit during operation, separate the records at the change and keep each section's units explicit. With both boards using a 40 MHz passive crystal, place hardware count, rendered value, and analyzer time side by side. A successful crystal check then cannot obscure the effect of the system divider.

Separate the timestamp scale from its origin if more than one device must be synchronized. Events a second apart give about one million counts with the one-microsecond setting. A difference of a few dozen counts raises different questions from a result of half a million counts. Check reference frequency, temperature, and event selection for small discrepancies. Verify the divider for a factor-of-two error. Two devices with the same count period can still start from different origins.

Keep the configuration readback and raw timestamp words. When reading a live counter in separate bytes, consider rollover during the reads. For stored frame timestamps, verify that the driver reads the intended receive element and does not mix transmit events into the series. Save the selected event, frame number, and clock configuration together so a ring buffer cannot silently combine two test runs.

If only one frame type differs, repeat with fixed payload and bit-rate settings before attributing the observed scale to the reference. Read the raw timestamps as part of qualification instead of relying on the CLKO screenshot.

References

WeChat

MERLIN · TIMING COMPONENTS

Scan with WeChat to contact Sales

Add our WeCom contacts from your usual WeChat app.

On desktop, scan with your phone. On mobile, save the QR image and select it from your album in WeChat Scan.