summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobert-hh <robert@hammelrath.com>2024-02-20 21:46:57 +0100
committerDamien George <damien@micropython.org>2024-08-20 12:26:45 +1000
commitd420b4e478267cf8c6c0136982bdeeedaccf3920 (patch)
tree837ef9b18846004b206253efbbb37c24942f61e1
parent26d91b897ea46a28f3d32cbe094b607124c1657d (diff)
rp2/main: Set the default clock frequency at boot.
As a side effect, the peripheral clock will be set to 48Mhz and both UART and I2C will not be affected by CPu speed changed using `machine.freq()`. With the change the UART baud rate range is 50 to 3_000_000. Signed-off-by: robert-hh <robert@hammelrath.com>
-rw-r--r--ports/rp2/main.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/ports/rp2/main.c b/ports/rp2/main.c
index 1ce1d2bf3..fa5495bf4 100644
--- a/ports/rp2/main.c
+++ b/ports/rp2/main.c
@@ -80,6 +80,9 @@ int main(int argc, char **argv) {
pendsv_init();
soft_timer_init();
+ // 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();
@@ -231,6 +234,10 @@ int main(int argc, char **argv) {
gc_sweep_all();
mp_deinit();
+ #if MICROPY_HW_ENABLE_UART_REPL
+ setup_default_uart();
+ mp_uart_init();
+ #endif
}
return 0;