You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's possible that if LSE crystal is used, the crystal won't have the exact frequency of 32.768 kHz. It looks to me that Rtc::select_frequency is not enough, as it allows only to set whole number frequencies. If I want to have RTC with 1 Hz, and the clock gets ahead by a second or two per day, the prescaler for RTC should be different than 1 Hz based precisely on 32.768 kHz. (should not be 32.768 / 1 - 1)
This HAL currently does not support adding or subtracting from the prescaler. This may be solved by writing to prlh and prll directly, but I would say that implementing support for some kind of a calibration like this is not out of scope of this HAL and could be implemented in Rtc.
What do you think about this? And what do you think the implementation should be? The best I came up with is making something like Rtc::select_precise_frequency(&mut self, frequency: Hertz, adjustment: u32), where adjustment would just be added to the prescaler.
I am up to PR this, but I am unsure 1. if this is in the scope of this HAL, 2. if the implementation I proposed makes sense, maybe it could be done better
The text was updated successfully, but these errors were encountered:
x1b6e6
added a commit
to x1b6e6/stm32f1xx-hal
that referenced
this issue
Oct 9, 2024
Fix `select_frequency` method with non LSE clock.
Allow custom frequencies for LSE and LSI clocks.
Fixstm32-rs#469
Signed-off-by: Timofey Denisenko <ftdabcde@gmail.com>
It's possible that if LSE crystal is used, the crystal won't have the exact frequency of 32.768 kHz. It looks to me that
Rtc::select_frequency
is not enough, as it allows only to set whole number frequencies. If I want to have RTC with 1 Hz, and the clock gets ahead by a second or two per day, the prescaler for RTC should be different than 1 Hz based precisely on 32.768 kHz. (should not be 32.768 / 1 - 1)This HAL currently does not support adding or subtracting from the prescaler. This may be solved by writing to prlh and prll directly, but I would say that implementing support for some kind of a calibration like this is not out of scope of this HAL and could be implemented in
Rtc
.What do you think about this? And what do you think the implementation should be? The best I came up with is making something like
Rtc::select_precise_frequency(&mut self, frequency: Hertz, adjustment: u32)
, where adjustment would just be added to the prescaler.I am up to PR this, but I am unsure 1. if this is in the scope of this HAL, 2. if the implementation I proposed makes sense, maybe it could be done better
The text was updated successfully, but these errors were encountered: