aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
author1-rafael-1 <[email protected]>2025-05-02 23:51:28 +0200
committer1-rafael-1 <[email protected]>2025-05-02 23:51:28 +0200
commit3441e805070c7efb7cad20a84d1986e215b4de3d (patch)
tree7bdc5ad9c015ad02e07ff45531b22095cabf2632 /examples
parenta33e7172f6bf7dc9590432dd62c2b71d0215d99d (diff)
first batch of changes after review
Diffstat (limited to 'examples')
-rw-r--r--examples/rp/src/bin/overclock.rs11
-rw-r--r--examples/rp/src/bin/overclock_manual.rs20
2 files changed, 14 insertions, 17 deletions
diff --git a/examples/rp/src/bin/overclock.rs b/examples/rp/src/bin/overclock.rs
index e3ac77340..f9a8c94d0 100644
--- a/examples/rp/src/bin/overclock.rs
+++ b/examples/rp/src/bin/overclock.rs
@@ -1,6 +1,6 @@
1//! # Overclocking the RP2040 to 200 MHz 1//! # Overclocking the RP2040 to 200 MHz
2//! 2//!
3//! This example demonstrates how to configure the RP2040 to run at 200 MHz using a higher level API. 3//! This example demonstrates how to configure the RP2040 to run at 200 MHz.
4 4
5#![no_std] 5#![no_std]
6#![no_main] 6#![no_main]
@@ -17,19 +17,18 @@ const COUNT_TO: i64 = 10_000_000;
17 17
18#[embassy_executor::main] 18#[embassy_executor::main]
19async fn main(_spawner: Spawner) -> ! { 19async fn main(_spawner: Spawner) -> ! {
20 // Set up for clock frequency of 200 MHz 20 // Set up for clock frequency of 200 MHz, setting all necessary defaults.
21 // This will set all the necessary defaults including slightly raised voltage 21 let config = Config::new(ClockConfig::crystal_freq(200_000_000));
22 let config = Config::new(ClockConfig::at_sys_frequency_mhz(200));
23 22
24 // Show the voltage scale for verification 23 // Show the voltage scale for verification
25 info!("System core voltage: {}", Debug2Format(&config.clocks.voltage_scale)); 24 info!("System core voltage: {}", Debug2Format(&config.clocks.core_voltage));
26 25
27 // Initialize the peripherals 26 // Initialize the peripherals
28 let p = embassy_rp::init(config); 27 let p = embassy_rp::init(config);
29 28
30 // Show CPU frequency for verification 29 // Show CPU frequency for verification
31 let sys_freq = clk_sys_freq(); 30 let sys_freq = clk_sys_freq();
32 info!("System clock frequency: {} Hz", sys_freq); 31 info!("System clock frequency: {} MHz", sys_freq / 1_000_000);
33 32
34 // LED to indicate the system is running 33 // LED to indicate the system is running
35 let mut led = Output::new(p.PIN_25, Level::Low); 34 let mut led = Output::new(p.PIN_25, Level::Low);
diff --git a/examples/rp/src/bin/overclock_manual.rs b/examples/rp/src/bin/overclock_manual.rs
index ad6abf0e7..35160b250 100644
--- a/examples/rp/src/bin/overclock_manual.rs
+++ b/examples/rp/src/bin/overclock_manual.rs
@@ -8,7 +8,7 @@
8use defmt::*; 8use defmt::*;
9use embassy_executor::Spawner; 9use embassy_executor::Spawner;
10use embassy_rp::clocks; 10use embassy_rp::clocks;
11use embassy_rp::clocks::{ClockConfig, PllConfig, VoltageScale}; 11use embassy_rp::clocks::{ClockConfig, CoreVoltage, PllConfig};
12use embassy_rp::config::Config; 12use embassy_rp::config::Config;
13use embassy_rp::gpio::{Level, Output}; 13use embassy_rp::gpio::{Level, Output};
14use embassy_time::{Duration, Instant, Timer}; 14use embassy_time::{Duration, Instant, Timer};
@@ -16,23 +16,21 @@ use {defmt_rtt as _, panic_probe as _};
16 16
17const COUNT_TO: i64 = 10_000_000; 17const COUNT_TO: i64 = 10_000_000;
18 18
19/// Configure the RP2040 for 200 MHz operation by manually specifying 19/// Configure the RP2040 for 200 MHz operation by manually specifying the PLL settings.
20/// all the required parameters instead of using higher-level APIs.
21fn configure_manual_overclock() -> Config { 20fn configure_manual_overclock() -> Config {
22 // Set the PLL configuration manually, starting from default values 21 // Set the PLL configuration manually, starting from default values
23 let mut config = Config::default(); 22 let mut config = Config::default();
24 23
25 // Set the system clock to 200 MHz using a PLL with a reference frequency of 12 MHz 24 // Set the system clock to 200 MHz
26 config.clocks = ClockConfig::manual_pll( 25 config.clocks = ClockConfig::manual_pll(
27 12_000_000, 26 12_000_000, // Crystal frequency, 12 MHz is common. If using custom, set to your value.
28 PllConfig { 27 PllConfig {
29 refdiv: 1, 28 refdiv: 1, // Reference divider
30 fbdiv: 100, 29 fbdiv: 100, // Feedback divider
31 post_div1: 3, 30 post_div1: 3, // Post divider 1
32 post_div2: 2, 31 post_div2: 2, // Post divider 2
33 }, 32 },
34 // For 200 MHz, we need a voltage scale of 1.15V 33 CoreVoltage::V1_15, // Core voltage, should be set to V1_15 for 200 MHz
35 Some(VoltageScale::V1_15),
36 ); 34 );
37 35
38 config 36 config