diff options
| author | 1-rafael-1 <[email protected]> | 2025-04-28 22:54:15 +0200 |
|---|---|---|
| committer | 1-rafael-1 <[email protected]> | 2025-04-28 22:54:15 +0200 |
| commit | 3a6dc910ffc66d4a30b89f299432b383271a719f (patch) | |
| tree | b053571d597b2030e1069397a93de05cf9939661 /examples/rp | |
| parent | b0594d16f238f803a0192810833ae2b0c3941ec3 (diff) | |
first working draft
Diffstat (limited to 'examples/rp')
| -rw-r--r-- | examples/rp/src/bin/overclock.rs | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/examples/rp/src/bin/overclock.rs b/examples/rp/src/bin/overclock.rs index 429fff1ac..db6c8f448 100644 --- a/examples/rp/src/bin/overclock.rs +++ b/examples/rp/src/bin/overclock.rs | |||
| @@ -3,22 +3,18 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_rp::clocks::{clk_sys_freq, ClockConfig}; | 6 | use embassy_rp::clocks::{clk_sys_freq, ClockConfig, VoltageScale}; |
| 7 | use embassy_rp::config::Config; | 7 | use embassy_rp::config::Config; |
| 8 | use embassy_rp::gpio::{Level, Output}; | 8 | use embassy_rp::gpio::{Level, Output}; |
| 9 | use embassy_time::{Duration, Instant, Timer}; | 9 | use embassy_time::{Duration, Instant, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | const COUNT_TO: i32 = 1_000_000; | 12 | const COUNT_TO: i64 = 10_000_000; |
| 13 | 13 | ||
| 14 | #[embassy_executor::main] | 14 | #[embassy_executor::main] |
| 15 | async fn main(_spawner: Spawner) -> ! { | 15 | async fn main(_spawner: Spawner) -> ! { |
| 16 | // Set up for clock frequency of 200 MHz | 16 | // Set up for clock frequency of 200 MHz |
| 17 | // We will need a clock config in the HAL config that supports this frequency | 17 | let config = Config::new(ClockConfig::with_speed_mhz(200)); |
| 18 | // The RP2040 can run at 200 MHz with a 12 MHz crystal | ||
| 19 | let config = Config::new(ClockConfig::crystal_freq(12_000_000, 200_000_000)); | ||
| 20 | |||
| 21 | // Initialize the peripherals | ||
| 22 | let p = embassy_rp::init(config); | 18 | let p = embassy_rp::init(config); |
| 23 | 19 | ||
| 24 | // Show CPU frequency for verification | 20 | // Show CPU frequency for verification |
| @@ -37,20 +33,19 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 37 | 33 | ||
| 38 | let start = Instant::now(); | 34 | let start = Instant::now(); |
| 39 | 35 | ||
| 40 | // Count to COUNT_TO | ||
| 41 | // This is a busy loop that will take some time to complete | 36 | // This is a busy loop that will take some time to complete |
| 42 | while counter < COUNT_TO { | 37 | while counter < COUNT_TO { |
| 43 | counter += 1; | 38 | counter += 1; |
| 44 | } | 39 | } |
| 45 | 40 | ||
| 46 | let elapsed = start - Instant::now(); | 41 | let elapsed = Instant::now() - start; |
| 47 | 42 | ||
| 48 | // Report the elapsed time | 43 | // Report the elapsed time |
| 49 | led.set_low(); | 44 | led.set_low(); |
| 50 | info!( | 45 | info!( |
| 51 | "At {}Mhz: Elapsed time to count to {}: {}ms", | 46 | "At {}Mhz: Elapsed time to count to {}: {}ms", |
| 52 | sys_freq / 1_000_000, | 47 | sys_freq / 1_000_000, |
| 53 | COUNT_TO, | 48 | counter, |
| 54 | elapsed.as_millis() | 49 | elapsed.as_millis() |
| 55 | ); | 50 | ); |
| 56 | 51 | ||
| @@ -58,3 +53,14 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 58 | Timer::after(Duration::from_secs(2)).await; | 53 | Timer::after(Duration::from_secs(2)).await; |
| 59 | } | 54 | } |
| 60 | } | 55 | } |
| 56 | |||
| 57 | // let config = Config::new(ClockConfig::with_speed_mhz_test_voltage(125, Some(VoltageScale::V1_10))); | ||
| 58 | // let config = Config::default(); | ||
| 59 | // let config = Config::new(ClockConfig::with_speed_mhz_test_voltage_extended_delay( | ||
| 60 | // 200, // Standard 125MHz clock | ||
| 61 | // Some(VoltageScale::V1_15), // 1.15V voltage | ||
| 62 | // Some(1000), // 1000μs (1ms) stabilization delay - significantly longer than default | ||
| 63 | // )); | ||
| 64 | // Initialize the peripherals | ||
| 65 | |||
| 66 | // let p = embassy_rp::init(Default::default()); //testing the bog standard | ||
