Skip to content

Conversation

Rutherther
Copy link
Contributor

So far, Rtc::select_frequency did not consider frequencies other than LSE_HERTZ, which was valid only for LSE with 32.768 kHz. For LSI, which has 40 kHz, and HSE, which may have an arbitrary frequency in a given range, the frequency was selected based on the wrong RTC frequency.

This PR aims to fix that. I've also refactored the new methods a bit, using the select_frequency instead of repeating the same code.

I've solved this by adding frequency field to the Rtc, there is no other way I could think of, as HSE frequency may be different depending on the crystal selected for specific application. As far as I understand it, LSE does not necessarily have to be 32.768 kHz, so maybe adding the possibility to change the frequency of LSE could prove useful as well? Adding the frequency field unfortunately introduces redundancy for LSI and (maybe) LSE.

@Rutherther
Copy link
Contributor Author

In my previous PR #466, I forgot to add the change to CHANGELOG.md, this PR adds that change to CHANGELOG as well.

So far, Rtc::select_frequency did not
take into account other frequency than LSE_HERTZ,
that was valid only for LSE that has 32.768 kHz.

For LSI, that has 40 kHz, and HSE, that may
have arbitrary frequency in a given range,
the frequency was selected based on wrong
RTC frequency.
Copy link
Contributor

@tmehr-enqt tmehr-enqt left a comment

Choose a reason for hiding this comment

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

Looks good to me, didn't test it but the logic looks fine.

@burrbull burrbull added this pull request to the merge queue Sep 4, 2025
Merged via the queue into stm32-rs:master with commit 24f18a4 Sep 4, 2025
11 checks passed
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