diff --git a/ports/rp2/main.c b/ports/rp2/main.c index 40374faff9..679bd440ac 100644 --- a/ports/rp2/main.c +++ b/ports/rp2/main.c @@ -76,6 +76,10 @@ int main(int argc, char **argv) { // This is a tickless port, interrupts should always trigger SEV. SCB->SCR |= SCB_SCR_SEVONPEND_Msk; + // set the MCU frequency and as a side effect the peripheral clock + // to 48 MHz. + set_sys_clock_khz(125000, false); + #if MICROPY_HW_ENABLE_UART_REPL bi_decl(bi_program_feature("UART REPL")) setup_default_uart(); @@ -227,6 +231,12 @@ int main(int argc, char **argv) { gc_sweep_all(); mp_deinit(); + // Reset the MCU frequency + set_sys_clock_khz(125000, false); + #if MICROPY_HW_ENABLE_UART_REPL + setup_default_uart(); + mp_uart_init(); + #endif } return 0; diff --git a/ports/rp2/modmachine.c b/ports/rp2/modmachine.c index 5551bf723a..366711b770 100644 --- a/ports/rp2/modmachine.c +++ b/ports/rp2/modmachine.c @@ -95,6 +95,12 @@ static void mp_machine_set_freq(size_t n_args, const mp_obj_t *args) { if (!set_sys_clock_khz(freq / 1000, false)) { mp_raise_ValueError(MP_ERROR_TEXT("cannot change frequency")); } + // Option: Set PERI clock to system clock again + // clock_configure(clk_peri, + // 0, + // CLOCKS_CLK_PERI_CTRL_AUXSRC_VALUE_CLK_SYS, + // SYS_CLK_KHZ * KHZ, + // SYS_CLK_KHZ * KHZ); #if MICROPY_HW_ENABLE_UART_REPL setup_default_uart(); mp_uart_init();