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

clk_ref_freq published anywhere ? #3773

Closed
mschnell1 opened this issue Jan 15, 2025 · 2 comments
Closed

clk_ref_freq published anywhere ? #3773

mschnell1 opened this issue Jan 15, 2025 · 2 comments

Comments

@mschnell1
Copy link

mschnell1 commented Jan 15, 2025

I found where TIMER0 is initialized in embassy and this involves setting the clock source in embassy/embassy-rp/src/clocks.rs.
Now I want to initialize TIMER1 (and decently use clock sources for other peripherals).
I seemingly should use the clk_ref_freq defined in embassy/embassy-rp/src/clocks.rs to calculate appropriate factors in a similar way as done for TIMER0. But I don't find a way to access this value. (Right now I calculate clk_ref_freq by reading back the factor from TIMER0:

let clk_ref_freq = pac::TICKS.timer0_cycles().read().0 * 1000000;

Nasty hack :) )
Is there an "official" way to get clk_ref_freq or another appropriate constant (derived from the Oscillator frequency)? I did not find anything in the documentation.

Also see #3766

@mschnell1
Copy link
Author

mschnell1 commented Jan 15, 2025

This said, IMHO there should be settable "features" defining the desired CPU clock (defaulting to the official max clock of the RP2040 rsp RP235x) and defining the crystal frequency (defaulting to what the BSP defines),
Will this affect the multiple "magic numbers" in fn crystal() fn rosc() etc ?

@mschnell1
Copy link
Author

finally found it:
embassy_rp::clocks::clk_ref_freq()
Thanks to anybody who read this

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

1 participant