Expand description
§Clock configuration for the RP2040 and RP235x microcontrollers.
§Clock Configuration API
This module provides both high-level convenience functions and low-level manual configuration options for the RP2040 clock system.
§High-Level Convenience Functions
For most users, these functions provide an easy way to configure clocks:
ClockConfig::system_freq(125_000_000)
- Set system clock to a specific frequency with automatic voltage scalingClockConfig::crystal(12_000_000)
- Default configuration with 12MHz crystal giving 125MHz system clock
§Manual Configuration
For advanced users who need precise control:
ⓘ
// Start with default configuration and customize it
let mut config = ClockConfig::default();
// Set custom PLL parameters
config.xosc = Some(XoscConfig {
hz: 12_000_000,
sys_pll: Some(PllConfig {
refdiv: 1,
fbdiv: 200,
post_div1: 6,
post_div2: 2,
}),
// ... other fields
});
// Set voltage for overclocking
config.core_voltage = CoreVoltage::V1_15;
§Examples
§Standard 125MHz (rp2040) or 150Mhz (rp235x) configuration
ⓘ
let config = ClockConfig::crystal(12_000_000);
Or using the default configuration:
ⓘ
let config = ClockConfig::default();
§Overclock to 200MHz
ⓘ
let config = ClockConfig::system_freq(200_000_000);
§Manual configuration for advanced scenarios
ⓘ
use embassy_rp::clocks::{ClockConfig, XoscConfig, PllConfig, CoreVoltage};
// Start with defaults and customize
let mut config = ClockConfig::default();
config.core_voltage = CoreVoltage::V1_15;
// Set other parameters as needed...
Structs§
- AdcClk
Config - ADC clock config.
- Clock
Config - CLock configuration.
- Gpin
- General purpose clock input driver.
- Gpout
- General purpose clock output driver.
- PllConfig
- PLL configuration.
- RefClk
Config - Reference clock config.
- Rosc
Config - On-chip ring oscillator configuration.
- RoscRng
- Random number generator based on the ROSC RANDOMBIT register.
- RtcClk
Config - RTC clock config.
- SysClk
Config - SYS clock config.
- UsbClk
Config - USB clock config.
- Xosc
Config - Crystal oscillator configuration.
Enums§
- AdcClk
Src - ADC clock source.
- Clock
Error - Clock error types.
- Core
Voltage - Core voltage regulator settings.
- Gpout
Src - Gpout clock source.
- Peri
ClkSrc - Peripheral clock sources.
- RefClk
Src - Reference clock source.
- Rosc
Range - ROSC freq range.
- RtcClk
Src - RTC clock source.
- SysClk
Src - SYS clock source.
- UsbClk
Src - USB clock source.
Traits§
Functions§
- clk_
adc_ freq - ADC clock frequency.
- clk_
peri_ freq - Peripheral clock frequency.
- clk_
ref_ freq - REF clock frequency.
- clk_
rtc_ freq - RTC clock frequency.
- clk_
sys_ freq - SYS clock frequency.
- clk_
usb_ freq - USB clock frequency.
- core_
voltage - The core voltage of the chip.
- dormant_
sleep - Enter the
DORMANT
sleep state. This will stop all internal clocks and can only be exited through resets, dormant-wake GPIO interrupts, and RTC interrupts. If RTC is clocked from an internal clock source it will be stopped and not function as a wakeup source. - pll_
sys_ freq - PLL SYS clock frequency.
- pll_
usb_ freq - PLL USB clock frequency.
- rosc_
freq - ROSC clock frequency.
- xosc_
freq - XOSC clock frequency.