Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change/set sys_clk frequency #625

Open
DmitriLyalikov opened this issue May 31, 2023 · 1 comment
Open

How to change/set sys_clk frequency #625

DmitriLyalikov opened this issue May 31, 2023 · 1 comment

Comments

@DmitriLyalikov
Copy link

Hi all,

I am looking at overclocking my sys_clk to speed up the pio state machines, at for example, 250 Mhz.

I am using the standard 12Mhz XOSC on board and want to either configure the SYS_PLL, or sys_clk at runtime.

I have the following:

        // Configure the clocks
        let clocks = hal::clocks::init_clocks_and_plls(
            XTAL_FREQ_HZ,
            c.device.XOSC,
            c.device.CLOCKS,
            c.device.PLL_SYS,
            c.device.PLL_USB,
            &mut resets,
            &mut watchdog,
        )

in clocks/mod.rs the trait has ClocksManager and I wonder if i can simply do:

        self.system_clock
            .configure_clock(pll_sys, pll_sys.get_freq())?;

and instead of pll_sys.get_freq() replace to HertzU32::MHz(248)?
If not, what is the correct mechanism to configure this? All help is appreciated.
Thanks
-Dmitri

@jannic
Copy link
Member

jannic commented May 31, 2023

It's not exactly as simple, as the clock source passed to configure_clock must have a higher frequency than the target frequency. So if you want to overclock, what you need to do is increase the frequency of pll_sys.

You can find a nice example how to do that in the Neotron BIOS:
https://github.com/Neotron-Compute/Neotron-Pico-BIOS/blob/develop/src/main.rs#L346-L404

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants