# Direct event counter — prototype 1.3 The XIAO RP2040 uses PWM slices 3 and 0 in B rising-edge input mode on D5/GPIO7 and D7/GPIO1. D0/GPIO26 enables the existing external dual AND gate. 3.3 V logic only; use suitable conditioning, decoupling, common signal reference, and gate pull-down. USB serial, not UART on D7. Never connect motor supply to GPIO. No RPM feedback. Start S and end E retain the three-field CSV protocol. The earlier firmware remains available. The 16-bit hardware counts are sampled continuously and modular differences accumulated in unsigned 64-bit totals. At 10 MHz a wrap occurs every 6.5536 ms. A conservative 5 ms maximum bracketed read gap gives margin; longer gaps invalidate the run and close the gate. Input frequency must not exceed 10 MHz (including tolerance; use a lower nominal frequency for qualification or revise the bound). This guard cannot detect all missed pulses, noise, or input overspeed. Timing is diagnostic only, not the measurement reference. No streaming output during acquisition. An automatic invalid record may arrive before E: verify host handling before using prior GUI, or use a serial terminal for commissioning. Do not reuse an invalid record as a measurement. No claim of target compilation or real hardware performance. ## Acceptance tests 1. Motor disconnected. Feed a calibrated 3.3 V pulse source to both channels; start at 1 Hz, then 100 Hz, 1 kHz, 100 kHz, 1 MHz, 5 MHz and just below 10 MHz. Verify duty cycle, rise/fall times, and gate transitions with a scope. Never exceed input electrical limits. Compare both counts and a separately calibrated counter on the same gated signals, not just one another (common losses can cancel). Repeat at different gate phases and channel swaps. 2. Asynchronous gate opening while an input is high can create an extra edge and closing can truncate pulses. Characterize these boundaries; no claim of a clean full-pulse gate. For ideal signals each channel's count differs from a true rising-edge interval count by at most one at opening, but real runt pulses and skew require measurement. Reject any unexplained discrepancy; report measured boundary uncertainty. 3. Test repeated wrap crossings and runs longer than 429.5 seconds near 10 MHz, then one hour. Check for overflow, USB stalls, invalid-record behavior and resets. Deliberately delay sampling in a test build to verify invalidation. Save failures. Do not run the motor until low-frequency and electrical isolation tests pass. 4. Repeat with independent optical sensor and reference, motor powered separately; check noise and pickup. Record actual edge-per-turn calibration. No centrifuge use until professionally qualified. At 3000 RPM and one edge/revolution, a one-hour count is 180000; two runs with one-count uncertainty each give approximately 1.11e-5 relative motor boundary uncertainty alone. The quartz count at 10 MHz is nominally 36 billion; two counts over two runs give 5.56e-11 reference boundary uncertainty alone. Actual errors may be larger. No evidence of a differential physical effect follows from simulations. Sources: https://www.raspberrypi.com/documentation/pico-sdk/hardware.html ; https://wiki.seeedstudio.com/XIAO-RP2040/ . Budget remains $100 preferred, $200 ceiling, stationary equipment only.