diff options
| author | Carl St-Laurent <[email protected]> | 2023-06-03 22:10:43 -0400 |
|---|---|---|
| committer | Carl St-Laurent <[email protected]> | 2023-06-03 22:10:43 -0400 |
| commit | 675499449fa3e348d27aebc5aae2b7f736648609 (patch) | |
| tree | 1f3232e39ac9198d6ea85c996a30b01b78aeacc1 /examples/stm32g4 | |
| parent | 2f269f32560ab178f62d08730909745f49b8eaef (diff) | |
Example using PLL
Diffstat (limited to 'examples/stm32g4')
| -rw-r--r-- | examples/stm32g4/src/bin/pll.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/stm32g4/src/bin/pll.rs b/examples/stm32g4/src/bin/pll.rs new file mode 100644 index 000000000..5dcdf4e53 --- /dev/null +++ b/examples/stm32g4/src/bin/pll.rs | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_stm32::rcc::{ClockSrc, PllClkDiv, PllM, PllN, PllSrc}; | ||
| 8 | use embassy_stm32::time::mhz; | ||
| 9 | use embassy_stm32::Config; | ||
| 10 | use embassy_time::{Duration, Timer}; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | ||
| 12 | |||
| 13 | #[embassy_executor::main] | ||
| 14 | async fn main(_spawner: Spawner) { | ||
| 15 | let mut config = Config::default(); | ||
| 16 | |||
| 17 | // Configure PLL to max frequency of 170 MHz | ||
| 18 | config.rcc.mux = ClockSrc::PLL(PllSrc::HSE(mhz(16)), PllM::Div4, PllN::Mul85, PllClkDiv::Div2); | ||
| 19 | |||
| 20 | let _p = embassy_stm32::init(config); | ||
| 21 | info!("Hello World!"); | ||
| 22 | |||
| 23 | loop { | ||
| 24 | Timer::after(Duration::from_millis(1000)).await; | ||
| 25 | info!("1s elapsed"); | ||
| 26 | } | ||
| 27 | } | ||
