From 839c324458f6900a58182d9aa23d846e8ec55c94 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 28 Aug 2026 16:40:07 +0700 Subject: rp2350: PIO-USB runs the pico-sdk stock 150 MHz Closes the sys-clock question. rp2350: the dynamic 156 MHz switch is removed - 150 MHz soak-tested clean (and a runtime switch truncates ETM capture on the trace carrier). rp2040 keeps its existing 120 MHz: soak sweeps show 120 = 8/8, stock 125 = 0/3 (bulk-OUT collapses, device NAKs ~600:1 with zero CRC errors on the wire), and 132 = 2/10 flaky despite an exact 12n/375k divider - no divider criterion predicts rp2040 PIO-USB health (the RX state machine samples at raw sysclk), so only soak-validated clocks ship. --- hw/bsp/rp2040/family.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/hw/bsp/rp2040/family.c b/hw/bsp/rp2040/family.c index 32b5c2312..9de1658eb 100644 --- a/hw/bsp/rp2040/family.c +++ b/hw/bsp/rp2040/family.c @@ -199,19 +199,12 @@ void board_init(void) trace_etm_init(); #if (CFG_TUH_ENABLED && CFG_TUH_RPI_PIO_USB) || (CFG_TUD_ENABLED && CFG_TUD_RPI_PIO_USB) - // Set the system clock to a multiple of 12mhz for bit-banging USB with pico-usb - #if defined(PICO_RP2350) && PICO_RP2350 == 1 - #ifdef TRACE_ETM - #error "TRACE_ETM pins clk_sys to 48 MHz (board.cmake) - too slow for PIO-USB, and a runtime clock switch desyncs the trace stream" - #endif - set_sys_clock_khz(156000, true); // rp2350 default is 150Mhz - #else + // rp2350 runs the pico-sdk stock 150 MHz (a runtime switch also truncates ETM + // capture). rp2040 keeps 120 MHz: soak-tested — the stock 125 MHz collapses + // PIO-USB bulk-OUT (device NAKs ~600:1, wire-measured, zero CRC errors). + #if !(defined(PICO_RP2350) && PICO_RP2350 == 1) set_sys_clock_khz(120000, true); // rp2040 default is 125Mhz #endif - // set_sys_clock_khz(180000, true); - // set_sys_clock_khz(192000, true); - // set_sys_clock_khz(240000, true); - // set_sys_clock_khz(264000, true); #ifdef PICO_DEFAULT_PIO_USB_VBUSEN_PIN gpio_init(PICO_DEFAULT_PIO_USB_VBUSEN_PIN); -- cgit v1.3.1