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

Why can RP2040 PIO miss a signal with the same 12 MHz crystal?

A board uses a 12 MHz passive crystal for an RP2040. A revision moves an external interface to different pins. The processor starts and the new pin shows the expected levels, but a PIO wait never completes. Identify the pin that the instruction monitors, then check when the state machine can observe it.

Distinguish absolute and relative pin numbers

The RP2040 data sheet defines separate WAIT GPIO and WAIT PIN sources. WAIT GPIO uses the absolute GPIO number. WAIT PIN uses an index relative to the state machine's input base. With GPIO10 as the base, PIN 2 means GPIO12. Moving the base to GPIO14 makes the same PIN 2 refer to GPIO16. An absolute GPIO12 wait still monitors the old pin. The two forms were only equivalent for the old mapping.

Apply distinct, long test signals at the two candidate pins and observe an instruction marker. A response to the old pin helps identify a mapping problem without depending on pulse width or phase. Check the generated program, read the input base, and record the connection between connector positions and physical GPIOs.

WAIT tests a level. If the pin is already high on entry to a high-level wait, execution can continue without a new rising edge. To require an observed low followed by high, arrange both conditions in the test. Exercise the case in which the external device starts with the line already high.

Budget synchronization separately from instruction timing

Assume the 12 MHz passive crystal feeds a configured 125 MHz system clock. Its period is eight nanoseconds. Raspberry Pi describes two input synchronizer cycles on the PIO path, giving a 16-nanosecond sampling contribution. If the state machine uses an integer divide of five, it executes at a 40-nanosecond cadence. The synchronizer's two clocks are system clocks, independent of that instruction interval.

External phase, the point at which the state machine examines WAIT, and subsequent output instructions also affect observed response. Sixteen nanoseconds is only one part of the latency. If a peripheral holds data briefly after its strobe, measure data validity and observe when the state machine actually samples it. Replacing the 12 MHz passive crystal does not remove the synchronizer or change the external data hold time.

The data sheet allows per-pin bypass where an interface meets setup and hold relative to the system clock. Keep synchronization for asynchronous signals. Bypassing it to shorten one bench trace can allow unstable input sampling and intermittent state-machine behavior. Review pulse width, clocking, and the instruction path first.

Check the mapping with long pulses before testing short ones

Verify the mapping with long levels, measure response using a marker and the documented clock settings, then sweep the phase of the shortest intended pulse. If only the old pin works, correct the mapping. If the new pin works with long pulses but fails intermittently with narrow inputs, inspect synchronization and the observation window.

Test replacement 12 MHz passive crystals for startup and frequency as required. For interface comparisons, keep the pin table and state-machine clock fixed. Save the connector label, GPIO number, WAIT argument, and scope traces together so another board revision can reproduce the result.

Looping an output back through the input adds a fixed pipeline

The RP2040 manual also describes one useful synchronizer check. Assume the state machine runs at the system clock with negligible external propagation. A pin modified through the PIO output path is seen through the input path after four system cycles with synchronization and two when bypassed. At 125 MHz derived from a 12 MHz passive crystal and the PLL, these examples correspond to 32 ns and 16 ns. This timing covers the internal output-to-input loop. Its starting point precedes the external transition used in an input-only measurement, and it does not describe the full program response when the state machine divides the clock by five. Verify that the state machine reads back the pad it actually drives and that bench wiring does not determine the logic level independently.

For an internal test, drive a known pin to a level that lasts long enough and read it with the state machine. A pass does not establish timing for a real sensor, whose pulses may arrive at any phase and may be short. In a separate run, drive the same input with an external generator and space the pulses so that the program returns to WAIT between events. Reduce pulse width and repeat across phases relative to the system clock. This separates a narrow pulse that was never sampled from one that arrived before the previous program loop finished. Record configuration and start phase separately for different state machines.

Save the target pad, WAIT instruction, synchronizer state, system clock, state machine divisor and longest observed delay. Mark an entirely missed event differently from the event captured one execution tick late. A miss calls for checking the pin and pulse width. A one-tick slip calls for a latency budget, particularly when the resulting output must align with another independent edge.

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.