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

Add clock_configure_mhz function #2244

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

will-v-pi
Copy link
Contributor

This adds a clock_configure_mhz function, which trades off accuracy compared to clock_configure (only gets to +/- 1MHz) for reduced code size as it doesn't need 64 bit division.

It takes the source and target frequencies in MHz as 16-bit numbers, to ensure they fit within the 32-bit division.

This is useful for example if you want to calibrate the ROSC using an XOSC and then run off the ROSC, in which case you don't need a very accurate frequency as the ROSC frequency isn't accurate.

Trades off accuracy (only gets to +/- 1MHz) for reduced code size as it doesn't need 64 bit division
@will-v-pi will-v-pi added this to the 2.1.2 milestone Feb 7, 2025
@kilograham
Copy link
Contributor

As per new code in #2225 we should catch cases where the divider between 1 and 2.

* \ingroup hardware_clocks
*
* This function differs from clock_configure in that it does not configure the clocks as accurately,
* but therefore doesn't need to bring in 64-bit division functions, reducing the code size.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reducing code size if 64-bit division is not otherwise used by the application

@lurch
Copy link
Contributor

lurch commented Feb 10, 2025

It takes the source and target frequencies in MHz as 16-bit numbers

I guess that means you can't overclock the Pico to 66 GHz? 🤣

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

Successfully merging this pull request may close these issues.

3 participants