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

Can a 12 MHz crystal restart in time for a 2 ms RP2040 dormant wake response?

Consider a battery-powered RP2040 data logger that spends most of its time dormant. An external controller raises a wake pin and expects an acknowledgement edge within 2 ms. Serial communication follows. The prototype accepts firmware and samples reliably while running, yet occasionally misses the acknowledgement deadline after dormancy. The interface has two milestones worth specifying. The first is when software can produce that acknowledgement edge. The second is when the peripheral has a usable operating clock. Different parts of the system can set those limits.

The oscillator has to restart after the wake edge

RP2040 dormant mode stops the selected oscillator. Before entry, firmware configures a wake event, switches internal clocks to the selected source and stops the PLLs. The external GPIO event then restarts the oscillator that was stopped. With the crystal oscillator, XOSC, the recovery path includes crystal startup and the configured delay. With the internal ring oscillator, ROSC, the system first recovers a faster-starting, less accurate clock. The datasheet's dormant-mode discussion gives an order of magnitude for the reference design, over 1 ms for the XOSC path and approximately 1 µs for ROSC. Those figures describe oscillator recovery. Check the actual board, firmware and peripheral before converting either figure into an external interface guarantee. Raspberry Pi RP2040 Datasheet, XOSC dormant mode

Some designs use the first UART byte as their wake marker. The UART may need to wait for the accurate clock, restore its divider and work through driver buffering. A late byte alone does not identify which stage caused the delay. Have a diagnostic build toggle one pin as soon as the dormant call returns and another after the normal clocks are back. Capture the wake input, those two markers and the actual acknowledgement on the same time base. The Raspberry Pi GPIO wake example restores clocks after the low-power call returns and then prints a message, which illustrates why a log line comes later. Raspberry Pi GPIO dormant example

The same 12 MHz crystal can have a firmware wait that differs by 5 ms

In Pico SDK 2.2.0, the common header sets the XOSC startup delay multiplier to six unless the board configuration overrides it. The implementation derives a base count from the crystal frequency and writes the result to the XOSC STARTUP register. At 12 MHz, integer division in (12000 + 128) ÷ 256 gives 47. A multiplier of six yields 282. Each register unit is 256 crystal periods, so the programmed time is 282 × 256 ÷ 12000000, or 6.016 ms. A board configuration explicitly using a multiplier of one writes 47, equivalent to about 1.003 ms. This calculation follows the SDK's assignment to the entire register, which leaves the optional ×4 bit clear. Pico SDK 2.2.0 multiplier definition Pico SDK 2.2.0 XOSC implementation RP2040 XOSC STARTUP register

These calculations give the programmed wait. Time to the first instruction also includes the hardware response to the wake stimulus. Actual crystal recovery across temperature, supply and loading needs to be measured. For a 2 ms handshake, an XOSC recovery path carrying a roughly 6 ms setting already exceeds the window. A multiplier of one nominally leaves about 1 ms for the other stages, with reliable startup still to verify. When production units miss the deadline, compare the preprocessed board configuration, the firmware actually flashed and the startup register. Two builds both specified for 12 MHz can still produce very different wake timelines.

Choose the edge to which the 2 ms specification applies

Suppose the interface requires only a GPIO acknowledgement within 2 ms and has a second signal for serial readiness. The board can wake via ROSC, acknowledge with a GPIO, then restart XOSC and the PLLs and restore the normal clocks. An illustrative allocation of 0.30 ms for wake to first marker and 0.40 ms for reading status and acknowledging totals 0.70 ms, leaving 1.30 ms against the 2.00 ms deadline. These figures are test allocations. If the other controller treats the acknowledgement as permission to transmit immediately, revise the handshake or keep the accurate clock running and budget the additional standby current. During the ROSC transition, check that firmware does not rely on timers or drivers still configured for the former clock rate.

On the bench, flash both configurations onto the same board and keep the wake level, pulse width and supply conditions constant. Keep the crystal part fixed first and compare the time to acknowledgement with the time to peripheral readiness. Then hold firmware fixed while comparing the original and candidate crystals. Log repeated wakes after short dormancy, the first wake after a long idle, minimum operating voltage and temperature endpoints. If no GPIO marker appears, inspect the wake setup and trigger waveform first. If the first marker appears but the functional response is late, look at clock restoration or peripheral enable. Record the probe point and input capacitance whenever you attach a probe. Probing a crystal pin can change the very startup behaviour being compared.

Include the receiving controller's actual acknowledgement criteria in the test. If it polls the pin level, even a timely edge can disappear before the next poll. Have the fixture record the pulse width, then verify the whole request and response with the production firmware. When no explicit error appears but no transfer follows, compare acknowledgement at the source, sampling by the other controller and the first transaction. Keep the same receiving firmware when swapping crystals.

Qualify a replacement crystal against the wake path

Check the candidate's frequency, package, load capacitance, maximum equivalent series resistance and allowable drive level against the circuit. Record the installed capacitors and series resistor. Raspberry Pi's hardware design guide gives a concrete crystal circuit to cross-check against the original design. A reference-design label on a schematic cannot capture actual implementation details, especially after changes to the board stack-up, pads or traces. Keep the wake source, SDK version, startup setting, both output edges and test conditions in the qualification record. A replacement can meet the steady-state frequency requirement and still extend wake recovery at the specified voltage or temperature enough to jeopardise the system deadline. Raspberry Pi Hardware design with RP2040, minimal design example

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.