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

Why should you recheck a SAM D21 UART after disconnecting a working USB link?

A SAM D21 acquisition board exchanges configuration with a PC over USB. On its independent supply, it sends sample records to a field instrument over a separate UART. During development the PC was always connected, and the serial monitor received complete records. In the field, some units show framing errors only after the native USB cable is disconnected. If the board uses crystal-less USB clock recovery, start with the power path, the firmware clock tree and the actual UART bit period. Successful enumeration is evidence for a condition with the relevant USB bus activity.

Trace the time bases for native USB and the physical UART

The SAM D21 can use the DFLL in USB clock recovery mode. With an active full-speed host, a Start of Frame marker arrives nominally every millisecond and supplies a 1 kHz reference. A multiplication factor of 48000 gives a nominal 48 MHz. In this mode the USB reference takes precedence over the selected generic clock reference. The DFLL can instead run in closed loop using a suitable generic clock path from an external 32.768 kHz crystal. Check the board definition, bootloader and application initialisation to establish which design is in use. The chip model alone does not identify it. Microchip also notes that DFLL status bits in USB recovery mode depend on USB activity, so correlate status with actual bus activity and measurements. Microchip SAM D21/DA1 datasheet, section 17.6.7 Microchip AT06475, section 2.2.3

Draw the GCLK_USB path and the path to the UART's GCLK_SERCOMx_CORE. If both use the same DFLL, baud rate on a connected board may benefit from the USB frame reference. If the UART has a separate generator, inspect that generator and check for UART reconfiguration by application code. Also establish whether the PC tool reads a physical UART through an adapter or the native USB virtual serial port. Document the supply path and verify that removing VBUS does not reset the board.

A standalone boot test can expose an easy-to-miss variable. If firmware preserves coarse and fine calibration values after seeing stable USB traffic, a board just unplugged and a freshly programmed board that has never seen USB can start from different tuning states. Record whether main power was fully removed, whether USB calibration had occurred, and how long the board remained disconnected. The manual describes ordinary closed-loop operation becoming effectively open loop without its reference, as well as the option to retain configuration through sleep. Correcting frequency when the reference returns and maintaining accuracy while it is absent are separate qualification criteria. Microchip datasheet, section 17.6.7 on reference loss and wake

Use measured bit periods to separate reference drift from divider error

Consider the arithmetic asynchronous mode at 16× oversampling, with a nominal 48 MHz reference and a target of 115200 bit/s. The datasheet equation gives a BAUD value of 65536 × (1 − 16 × 115200 ÷ 48000000), or about 63019.42. Writing 63019 gives approximately 115219 bit/s on an average-frequency basis, an error of roughly +0.017%. Suppose the detached reference runs 1% faster with BAUD unchanged. The calculated line rate likewise rises by 1%, to about 116371 bit/s. This assumed shift demonstrates scaling. It is not a DFLL specification for operation without SOF. Microchip datasheet, sections 25.6.2.3 and 26.6.2.6.4

Capture repeated 0x55 bytes with a logic analyser. Verify the analyser sample clock and trigger, then measure several transition intervals and their mean. The example gives about 8.679 µs per bit for the connected configuration and 8.593 µs for the assumed +1% case. Decoder success alone can hide the shift because the receiver's sampling and clock have their own tolerances. Preserve the raw trace alongside a routed reference clock if available. That helps distinguish a rate change from receiver configuration or degraded signal integrity. If register logs are needed, use a path that does not bring the native USB connection back into the test.

For a bidirectional product, also let the instrument transmit long frames and log receive errors on the board. The scope measurement describes the board's transmit rate. When the board receives, the instrument clock enters the error budget in the opposite role. Datasheet receiver tolerance depends on data bits, parity and oversampling. Alternating bytes are convenient for measuring edges. Qualification should also cover actual frame lengths and sustained transfers, with stop-bit errors, dropped packets and any masked retries recorded.

Begin standalone qualification with a cold boot and no USB

Run three trials on the same board. First, cold boot from the independent supply with no USB at any point. Record UART bit periods at first transmission and after the board warms up. Second, connect a host while the board stays powered, record both sides of the transition to active USB, and unplug while the external instrument is still communicating. Third, leave the cable attached and exercise suspend and resume, logging framing errors and the time to recovery. Hold the receiver, cable, baud setting and capture script constant. Align SOF activity, the UART and supply voltage on a common timeline where practical. A test that starts connected and only then unplugs can mistake a recently calibrated transient for long-term standalone behaviour. Captures from cold and warmed-up conditions help identify temperature and operating-state effects.

A crystal-referenced closed loop also needs its own multiplier. For an undivided nominal reference of 32768 Hz, an illustrative integer multiplier of 1465 gives 48005120 Hz, about 106.7 ppm above 48 MHz. This is solely the nominal multiplier offset. The production budget also includes the crystal tolerance, residual closed-loop error and UART divider error. On a cold boot with the independent reference, confirm that clock readiness precedes the first real transmission.

If the product must meet its UART timing indefinitely without USB, there are two sourcing decisions to review. One is to fit the 32.768 kHz XOSC32K crystal and load capacitors and verify whether it is configured as the independent DFLL reference or serves a different branch. The other is to put the UART on an accurate standalone reference and retain USB recovery for the USB branch. For the crystal option, qualify loading, equivalent series resistance, temperature and ageing allowance and startup time. Both options require verification in both supply states. A SparkFun community user comparing builds on the same device family traced a difference to a bootloader using an external crystal and an application using USB SOF. Record those choices in the board configuration alongside the oscillator part number. SparkFun discussion of SAM D21 crystal and USB recovery configurations

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.