🛠 Console série sur RP2350 : USB CDC natif et UART0 de secours

RP2350 (generic / RP2350-based boards) · debutant · Schéma : IMG-rp2350-generic-debutant-2-rp2350-console-serie-uart.svg — carte RP2350 générique branchée en USB sur un PC (console CDC), et en parallèle un adaptateur USB-TTL relié à GP0 (TX0) et GP1 (RX0) avec masse commune, terminal à 115200 bauds

Objectives

The RP2350 integrates a single USB controller: USB 2.0 Full-Speed device (12 Mb/s) and Full/Low-Speed host with an integrated 1.1 PHY (RP2350 datasheet, §12 USB). Under MicroPython, the console uses this native USB CDC — there is no serial chip on the board. However, as soon as USB is occupied (HID mode, battery power) or the USB pins are not wired (poorly soldered Pro Micro, bare module), you need UART: the RP2350 has 2 UARTs mappable to any GPIO. This tutorial sets up both fallback methods.

Hardware

Complete Code

# main.py — printf sur USB CDC ET trace sur UART0 (GP0/GP1, 115200 8N1)
import sys
from machine import UART, Pin
import time

# 1) La console par défaut est l'USB CDC natif du RP2350 :
print('Bonjour depuis USB CDC')      # visible dans Thonny / mpremote

# 2) Console de secours indépendante sur UART0 :
uart = UART(0, baudrate=115200, tx=Pin(0), rx=Pin(1))
uart.write('RP2350 pret (UART0 115200 8N1)\r\n')

n = 0
while True:
    n += 1
    msg = 'tick %d uptime_ms=%d\r\n' % (n, time.ticks_ms)
    sys.stdout.write(msg)             # USB CDC
    uart.write(msg)                   # UART0 physique
    if uart.any:                    # écho de ce que le PC envoie
        uart.write('recu: ' + uart.read.decode(errors='replace') + '\r\n')
    time.sleep_ms(500)

Expected Verification

Two windows, same lines: Thonny (board's CDC port) and your serial terminal on the adapter (115200 8N1 — picocom -b 115200 /dev/ttyUSB0, or the COM port under Windows). A character typed on the adapter side returns as an echo. Unplug the board's USB while keeping it powered at 5 V on VREG_VIN (2.7–5.5 V): the UART trace continues — you have a console decoupled from USB, essential for debugging a program that crashes USB enumeration.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials