🛠 Advanced Startup: UEXT-CH390 and Raspberry Pi Pico
Objectives
This tutorial aims to initialize wired 10/100 Mbps Ethernet communication between an RP2040 microcontroller and the UEXT-CH390 module. Unlike beginner approaches, we focus here on precise SPI interface configuration and SRAM buffer optimization to ensure reliable network stability.
Required Materials
- Raspberry Pi Pico or Pico 2 board (RP2040/RP2350)
- Olimex UEXT-CH390 module
- USB-C cable for power and flashing
- Dupont wires or compatible UEXT connector
- Development environment: Arduino IDE or Raspberry Pi Pico SDK (C/C++)
Steps
- Hardware Verification: Inspect the UEXT-CH390 module. Ensure the pUEXT connector pins (1.0 mm pitch) align with the Pico's SPI pins. The module operates at 3.3V; never connect to 5V.
- SPI Connection: If not using a dedicated UEXT connector, connect the Pico's SPI pins to the module. Use the default SPI0 bus for standard software compatibility. Verify polarity and phase for SPI modes 0 or 3, supported up to 72 MHz.
- Software Configuration: In your IDE, select the "Raspberry Pi Pico" board. Import the specific CH390 driver library developed for RP2040. Define the CS (Chip Select) pins and MISO/MOSI lines in the code.
- Initialization: In the
setup()function, call the CH390 initialization routine. The integrated MAC/PHY controller requires a precise reset sequence to load internal registers and activate the 16KB SRAM for packet buffering. - Link Test: Connect an RJ45 Ethernet cable from the module to your router. The link LED should light up. Display the factory-programmed MAC address via the serial port to confirm hardware detection.
Verification
Open the serial monitor at 115200 bauds. You should see a message confirming CH390 initialization and the display of the MAC address. If the message fails, check the 3.3V power supply and SPI connections. Once initialization is successful, attempt a ping to the DHCP-assigned IP address to validate the network layer.
To Go Further
Explore integration with ESPHome for automatic Home Assistant discovery. For maximum performance, study the lwIP driver for the Pico SDK to manage OTA updates and the local web interface directly on the microcontroller.
Other tutorials for this board
Code examples for this board
esp32-ch390-lwip-station.inoC++rp2040-pico-ch390-micropython.pyPythonesp32-ch390-udp-sensor-gateway.inoC++esp32-ch390-web-server-local.inoC++rp2040-ch390-iot-home-assistant.inoYAMLrp2040-lwip-ethernet-ping-6.inoC/C++ (Raspberry Pi Pico SDK)