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

Removed second division by refdiv #691

Merged
merged 2 commits into from
Sep 16, 2023
Merged

Conversation

vinsynth
Copy link
Contributor

While setting up a custom clock with refdiv = 2, I noticed it's post division frequency was half it's expected value; it seems that when making a new PhaseLockedLoopDevice, division of the reference frequency by refdiv occurs twice, which I assume is unintentional.

@9names
Copy link
Member

9names commented Sep 16, 2023

It's not obvious to me where this second division by refdiv occurs, would you mind pointing it out?

@jannic
Copy link
Member

jannic commented Sep 16, 2023

@9names: A few lines above, ref_freq_hz is calculated as:

        let ref_freq_hz: HertzU32 = xosc_frequency
            .to_Hz()
            .checked_div(u32::from(config.refdiv))
            .ok_or(Error::BadArgument)?
            .Hz();

So that value is already xosc_frequency / refdiv. Dividing it again looks wrong.

The patch LGTM.
(Of course, rustfmt should be applied.)

@jannic jannic merged commit c47cb04 into rp-rs:main Sep 16, 2023
8 checks passed
@vinsynth vinsynth deleted the feature/fix-refdiv branch September 16, 2023 08:10
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