Skip to content

Changing system clock sets peripheral clock to 48MHz #841

@msearle5

Description

@msearle5

At boot, the system and peripheral clocks both appear to be 125MHz.
If the system clock is later set (to any speed, even 125MHz), the peripheral clock is set to 48MHz.
I haven't measured the peripheral clock directly, but I have used a modified version of the FatFS "example" app:
https://github.com/msearle5/no-OS-FatFS-SD-SPI-RPi-Pico - which has a "cpu" command to set the system clock and a "spi" command to set the SPI (divided from peripheral) clock. At boot, SPI clocks of 62.5, 31.25, 20.833 etc. MHz can be set implying 125MHz peripheral clock, while after setting the system clock only clocks of 24MHz, 12MHz etc. can be set implying 48MHz peripheral clock.
Setting the system clock with set_sys_clock_khz() calls set_sys_clock_pll() in pico-sdk/src/rp2_common/pico_stdlib/stdlib.c. line 39..64 and line 64 looks as if it's setting clk_peri to 48MHz from the USB clock in all cases, while I would expect it to be set to the same as the system clock.
(Maybe the fault is my expectation, and this is intentional. But if nothing else it was surprising to me, so I would recommend documenting it - the relevant section of the manual here https://raspberrypi.github.io/pico-sdk-doxygen/group__pico__stdlib.html doesn't mention the peripheral clock.)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions