Pi Pico - 12Mhz CLOCK_FREQ?

Just added a Raspberry Pi Pico and an ADXL and noticed that Klipper is reporting the CLOCK_FREQ at only 12Mhz?

mcu 'pico': Starting serial connect
Loaded MCU 'pico' 94 commands (v0.10.0-256-g6d7c0336 / gcc: (15:8-2019-q3-1+b1) 8.3.1 20190703 (release) [gcc-8-branch revision 273027] binutils: (2.35.2-2+14+b2) 2.35.2)

MCU 'pico' config: 
ADC_MAX=4095 
BUS_PINS_i2c0a=gpio0,gpio1 
BUS_PINS_i2c0b=gpio4,gpio5 
BUS_PINS_i2c0c=gpio8,gpio9 
BUS_PINS_i2c0d=gpio12,gpio13 
BUS_PINS_i2c0e=gpio16,gpio17 
BUS_PINS_i2c0f=gpio20,gpio21 
BUS_PINS_i2c0g=gpio24,gpio25 
BUS_PINS_i2c0h=gpio28,gpio29 
BUS_PINS_i2c1a=gpio2,gpio3 
BUS_PINS_i2c1b=gpio6,gpio7 
BUS_PINS_i2c1c=gpio10,gpio11 
BUS_PINS_i2c1d=gpio14,gpio15 
BUS_PINS_i2c1e=gpio18,gpio19 
BUS_PINS_i2c1f=gpio22,gpio23 
BUS_PINS_i2c1g=gpio26,gpio27 
BUS_PINS_spi0a=gpio0,gpio3,gpio2 
BUS_PINS_spi0b=gpio4,gpio7,gpio6 
BUS_PINS_spi0c=gpio16,gpio19,gpio18 
BUS_PINS_spi0d=gpio20,gpio23,gpio22 
BUS_PINS_spi1a=gpio8,gpio11,gpio10 
BUS_PINS_spi1b=gpio12,gpio15,gpio14 
BUS_PINS_spi1c=gpio24,gpio27,gpio26 
CLOCK_FREQ=12000000 
MCU=rp2040 
PWM_MAX=255 
STATS_SUMSQ_BASE=256 
STEPPER_BOTH_EDGE=1

mcu_temperature 'pico' nominal base=437.226612 slope=-1917.489831

Raspberry Pi foundation states “up to 133Mhz”: Raspberry Pi Documentation - Raspberry Pi Pico

Not that the faster speeds are necessary to get the resonance calculations down, but there is a big difference between 12Mhz and 133Mhz.

Mainsail is also reporting 12Mhz.

I double checked the make menuconfig and there is no options for clock speed.

I’m going to guess that Klipper is reporting the 12Mhz crystal speed, not the processor speed?

Thanks!

1 Like

Yes. The rp2040 cores are setup to run at 125Mhz (that’s what the rp2040 sdk uses - even though the chip is rated at 133Mhz - so Klipper currently does the same). The value reported in the above tools is the “software timer frequency” which doesn’t always match the cpu core frequency. So, what you are observing is normal and expected.

In case anyone is curious, the rp2040 has an ARM cortex-M0+ core, which doesn’t have a readily available 32bit cpu core timer (unlike the ARM cortex-M3/M4 and similar cores). So, Klipper uses the rp2040 hardware timer for scheduling tasks. We configure that timer to 12Mhz - which matches the external crystal speed.

-Kevin

4 Likes

@koconnor thank you for the detailed explanation. It was very helpful.

Is there any way to overclock the freq mhz when making the .uf2. In which file do i need to change the frequency in src/rp2040. Thanks

See RFC RP2040: set clock to 200Mhz by nefelim4ag ¡ Pull Request #6829 ¡ Klipper3d/klipper ¡ GitHub