clock_conf.h File Reference

Clock configuration for the RP2350. More...

Detailed Description

Clock configuration for the RP2350.

Author
Tom Hert git@a.nosp@m.nnsa.nosp@m.nn.eu

Definition in file clock_conf.h.

#include "RP2350.h"
#include "macros/units.h"
+ Include dependency graph for clock_conf.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

#define XOSC_CTRL_FREQ_RANGE_VALUE_1_15MHZ   0xaa0u
 1-15 MHz range More...
 
#define XOSC_CTRL_FREQ_RANGE_VALUE_10_30MHZ   0xaa1u
 10-30 MHz range
 
#define XOSC_CTRL_FREQ_RANGE_VALUE_25_60MHZ   0xaa2u
 25-60 MHz range
 
#define XOSC_CTRL_FREQ_RANGE_VALUE_40_100MHZ   0xaa3u
 40-100 MHz range
 
#define XOSC_CTRL_ENABLE_VALUE_DISABLE   0xd1eu
 Disable the XOSC.
 
#define XOSC_CTRL_ENABLE_VALUE_ENABLE   0xfabu
 Enable the XOSC.
 
#define XOSC_CTRL_ENABLE_LSB   12u
 LSB of the enable bit.
 
#define XOSC_STATUS_STABLE_BITS   0x80000000u
 Stable bit in the XOSC status register.
 
#define XOSC_HZ   MHZ(12u)
 Default crystal frequency is 12 MHz.
 
#define PLL_REF_DIV   2u
 Reference divider for the PLL, set to 2 as per hardware manual.
 
#define PLL_VCO_FREQ   750000000u
 VCO frequency for the PLL, set to 750 MHz as per hardware manual.
 
#define PLL_PD1   6u
 Post divider 1 for the PLL, set to 6 as per hardware manual.
 
#define PLL_PD2   2u
 Post divider 2 for the PLL, set to 2 as per hardware manual.
 
#define PLL_PWR_PD_BITS   0x00000001u
 Power down bits for the PLL.
 
#define PLL_PWR_VCOPD_BITS   0x00000020u
 VCO power down bits for the PLL.
 
#define PLL_CS_LOCK_BITS   0x80000000u
 Lock bit in the PLL control status register.
 
#define PLL_PRIM_POSTDIV1_LSB   16u
 LSB of the post divider 1 in the PLL primary register.
 
#define PLL_PRIM_POSTDIV2_LSB   12u
 LSB of the post divider 2 in the PLL primary register.
 
#define PLL_PWR_POSTDIVPD_BITS   0x00000008u
 Post divider power down bits for the PLL.
 
#define CLK_PERI_CTRL_ENABLE_BIT   (1u << 11u)
 Enable bit for the peripheral clock control register.
 
#define CPUFREQ   125000000u
 Default CPU frequency in Hz, set to 125 MHz as per hardware manual.
 
#define CLOCK_XOSC_MAX   MHZ(15u)
 Maximum crystal frequency.
 
#define CLOCK_XOSC_MIN   MHZ(5u)
 Minimum crystal frequency.
 
#define CLOCK_XOSC   (XOSC_HZ)
 Crystal frequency.
 
#define PLL_POSTDIV_MIN   1u
 Minimum value of the post PLL clock divers.
 
#define PLL_POSTDIV_MAX   7u
 Maximum value of the post PLL clock divers.
 
#define PLL_VCO_FEEDBACK_SCALE_MIN   16u
 Minimum value of the PLL VCO feedback scaler.
 
#define PLL_VCO_FEEDBACK_SCALE_MAX   320u
 Maximum value of the PLL VCO feedback scaler.
 
#define PLL_REF_DIV_MIN   1u
 Minimum value of the clock divider applied before feeding in the reference clock into the PLL.
 
#define PLL_REF_DIV_MAX   1u
 Minimum value of the clock divider applied before feeding in the reference clock into the PLL.
 
#define PLL_FEEDBACK_DIVIDER_VALUE   125u
 PLL feedback divider value, set to 125 as per hardware manual.
 
#define CLK_SYS_PERI_CTRL_ENABLE_BIT   (1u << 0u)
 Enable bit for the system clock control register to select the peripheral clock.
 
#define CLK_SYS_SELECTED_PERI_FIELD_VALUE   2u
 Selected field value for the system clock control register to select the peripheral clock.
 
#define CLOCK_CORECLOCK   MHZ(12u)
 RIOT core clock frequency defined as the CPU frequency.
 
#define PDIV   ((PLL_PD1 << PLL_PRIM_POSTDIV1_LSB) | (PLL_PD2 << PLL_PRIM_POSTDIV2_LSB))
 Post divider for the PLL, calculated based on the post divider values.
 
#define FBDIV   ((PLL_VCO_FREQ / XOSC_HZ) / PLL_REF_DIV)
 Feedback divider for the PLL, calculated based on the VCO frequency and reference clock frequency.
 
void xosc_start (void)
 Configures the Crystal to run. More...
 
void xosc_stop (void)
 Stop the crystal.
 
void xosc_sleep (int32_t cycles)
 Sleep for a given number of cycles.
 
void clock_reset (void)
 Reset the clock system. More...
 
void cpu_clock_init (void)
 Configures the XOSC and then sets CLK_SYS, PLL_SYS and CLK_PERI to it. More...
 

Macro Definition Documentation

◆ XOSC_CTRL_FREQ_RANGE_VALUE_1_15MHZ

#define XOSC_CTRL_FREQ_RANGE_VALUE_1_15MHZ   0xaa0u

1-15 MHz range

See also
hardware/regs/xosc.h and chapter 8.2.8

Definition at line 25 of file clock_conf.h.

Function Documentation

◆ clock_reset()

void clock_reset ( void  )

Reset the clock system.

This function resets the clock system to a known state. It is recommended to call this function before configuring the clock system.

◆ cpu_clock_init()

void cpu_clock_init ( void  )

Configures the XOSC and then sets CLK_SYS, PLL_SYS and CLK_PERI to it.

Warning
Make sure to call clock_reset() before this function to reset the clock system
See also
RP2350 Docs Chapter 8, mostly 8.2 for more details

◆ xosc_start()

void xosc_start ( void  )

Configures the Crystal to run.

See also
The reference hardware manual suggests to use a 12 MHz crystal, which we use by default.