This project contains a library for RP2350 microcontroller and a stand-alone project for Pico 2 board. It captures up to 27 logic signals with support for run-length-encoding of the captured data.
The RLE compression means that even long captures do not take much space if there are spans where none of the trigger signals change state. The encoding is done in PIO, freeing CPU for other tasks.
This project is designed for taking long captures (can be multiple minutes long) of signals that are not constantly changing. It does not achieve as high samplerate as non-compressing logic analyzers.
The performance depends on CPU clockrate. RP2350 runs fairly stable at 250 MHz, which is what the example project uses.
Timing accuracy is +- 3 clock cycles (+- 12 ns). Shortest pulse that is reliably captured is 10 clock cycles (40 ns).
The available RAM and storage writing speed limit the length of a burst that can be captured. After a buffer overrun, the sniffer encodes a visually distinctive all-channels-glitch pulse to signify the lost data and continues recording new events.
The sniffer is designed to require only minimal CPU processing time, and it can be integrated with other applications for debugging purposes. This repository contains a platformio library which you can import to your own projects.
The sniffer can capture the state of both output and input pins, i.e. you can use it to monitor the signals generated by RP2350 internal peripherals.
Customize the sniffer settings in either platformio.ini or by copying rp2350_sniffer_config_example.h into rp2350_sniffer_config.h in your own project. Take a look at src/main.c for how to call the library.
When integrated into a project, the sniffer supports customizing the pin names used in the decoded capture. You can also include log text data and up to 8 custom data streams into the sniffer output.
The sniffer firmware for Pico 2 is built with PlatformIO:
pio run
Using a Pico 2 board, press down the BOOTSEL button and connect it to usb. Then run the upload command:
pio run --target upload
Reconnect the USB and the LED should blink slowly to signal that the board is ready to capture. Run the Python script to start the capture, which should cause the LED to blink quickly:
python3 utils/decode_sniff.py /dev/ttyACM0 (For Linux)
python3 utils/decode_sniff.py COM1 (For Windows)
When you have captured enough data, press ctrl-c to end. The VCD file can then be imported to PulseView for viewing.
Use decode_sniff_data_rp2350.py to decode the captured files:
python decode_sniff_data_rp2350.py sniff.dat
The file has 20 magic bytes RP2350_Logic_Sniffer at the beginning of the capture.
Logic data is organized as 32-bit words:
- Bits 31..27:
D, short time delta - Bits 26..0:
P, pin states or long time delta
If D != 31, then P is the new state of the 27 IO pins.
Clock cycles since previous sample is 3 * (32 - D)
If D == 31 and P <= 0x03FFFFFF, then P is a long time delta.
Pin states have not changed and clock cycles is 3 * (0x03FFFFFF - P + 3)
If D == 31 and 0x03FFFFFF < P <= 0x07FFFFFE, these are used by CPU as follows:
0xFCttttttindicates system timestamp in milliseconds0xFF00nnnnindicates sniffer format version0xFF01nnnnindicates CPU clock rate in MHz0xFF80nnnnn bytes of IO pin names or padding zeros follow0xFF81nnnnn bytes of system log data follows0xFF8Xnnnnn bytes of custom auxiliary data
If D == 31 and P == 0x07FFFFFF (whole word is all ones), then maximum time delta
has passed. Clock cycles is 3 * (0x03FFFFFF + 2) (approx 1 second @ 200 MHz)
This library has been developed by Rabbit Hole Computing™ for use in its ZuluSCSI and ZuluIDE products.
The library is licensed under MIT license.