# RP2040-ETH Documentation ## Overview The Waveshare RP2040-ETH is a compact microcontroller board that combines the Raspberry Pi RP2040 chip with built-in Ethernet connectivity. It provides a powerful dual-core processor with integrated networking capabilities in a small form factor. ## Hardware Specifications ### Processor - **Chip**: Dual-core Arm Cortex M0+ processor - **Clock Speed**: Flexible clock up to 133 MHz - **Memory**: 264KB SRAM - **Storage**: 4MB onboard Flash memory (W25Q32JVSSIQ NOR-Flash) ### Ethernet - **Ethernet Chip**: CH9120 with integrated TCP/IP protocol stack - **Capabilities**: - TCP Server/Client modes - UDP Server/Client modes - **Connector**: RJ45 Ethernet port ### I/O and Interfaces - **GPIO**: 14 multi-function GPIO pins - **USB**: Type-C connector (USB 1.1 host/device support) - **Special Features**: - 8 Programmable I/O (PIO) state machines - Temperature sensor - Castellated module design for board integration - Compatible with some Pico HATs ### Power - **Regulator**: RT9013-33GB 500mA Low Dropout LDO - **Programming**: Drag-and-drop via USB mass storage ## Programming the RP2040-ETH ### Development Options - C/C++ SDK - MicroPython - Arduino IDE ### What We've Learned From our WS2812 LED control implementation: 1. **PIO Usage**: The RP2040's PIO (Programmable I/O) is excellent for timing-critical operations like WS2812 LED control. We used PIO0 with state machine 0 to generate precise timing signals. 2. **Clock Configuration**: The default system clock works well for most applications. We commented out `set_sys_clock_48()` as it wasn't necessary for our WS2812 implementation. 3. **Pin Mapping**: GPIO 25 was used for WS2812 data output in our example, demonstrating the flexibility of pin assignment on the RP2040. 4. **Timing Precision**: The PIO handles the 800kHz timing requirement of WS2812 LEDs perfectly, showing the RP2040's capability for real-time signal generation. 5. **Memory Efficiency**: With 264KB of SRAM, there's plenty of room for complex applications beyond simple LED control. ### Code Structure Example Our WS2812 implementation demonstrates key RP2040 programming patterns: ```c // PIO initialization PIO pio = pio0; int sm = 0; uint offset = pio_add_program(pio, &ws2812_program); ws2812_program_init(pio, sm, offset, 25, 800000, true); // Color data formatting (GRB format for WS2812) uint32_t mask = (green << 16) | (red << 8) | (blue << 0); put_pixel(mask); ``` ### Key Takeaways 1. **Hardware Abstraction**: The Pico SDK provides excellent hardware abstraction layers, making it easy to work with complex peripherals. 2. **PIO Power**: The programmable I/O blocks are one of the RP2040's strongest features, enabling precise timing without CPU intervention. 3. **Development Workflow**: The USB mass storage programming mode makes development iteration very fast - just drag and drop the UF2 file. 4. **Ethernet Integration**: While our example doesn't use Ethernet, the CH9120 chip provides a straightforward path to network connectivity without complex TCP/IP stack implementation. ## Future Considerations - The Ethernet functionality via CH9120 opens possibilities for IoT applications - The dual-core processor allows for concurrent tasks (e.g., LED animation on one core, network communication on the other) - The castellated edges make this board ideal for integration into custom PCBs - PIO state machines can be used for various protocols beyond WS2812 (SPI, I2C variants, custom protocols)