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

Make RTC prescaler uint32 #520

Closed
me21 opened this issue May 17, 2018 · 4 comments
Closed

Make RTC prescaler uint32 #520

me21 opened this issue May 17, 2018 · 4 comments

Comments

@me21
Copy link
Contributor

me21 commented May 17, 2018

The RTC prescaler register allows 20 bits wide values to be written, whereas RTClock library uses uint16 for prescaler argument:

RTClock(rtc_clk_src src, uint16 prescaler );

My device has 12 MHz crystal. The prescaler should be 93749 (12000000/128) in my case, but it won't fit into uint16 argument.
The underlying rtc_set_prescaler_load function, which is used internally, already uses uint32 argument.
Please update the library to use uint32 instead.

@rogerclarkmelbourne
Copy link
Owner

Can you do a PR for this?

@rogerclarkmelbourne
Copy link
Owner

BTW.
It looks like you need to change RTClock.h and RTClock.cpp because the low level api function

already takes 32 bits and seems to send write it into 2 separate registers in 16 bit chunks

void rtc_set_prescaler_load(uint32 value) {
rtc_clear_sync();
rtc_wait_sync();
rtc_wait_finished();
rtc_enter_config_mode();
RTC->regs->PRLH = (value >> 16) & 0xffff;
RTC->regs->PRLL = value & 0xffff;
rtc_exit_config_mode();
rtc_wait_finished();
}

@me21
Copy link
Contributor Author

me21 commented May 18, 2018

Yeah, I totally agree. I will make a PR, I already have made the changes locally.

@me21
Copy link
Contributor Author

me21 commented May 21, 2018

@rogerclarkmelbourne Please take a look.

minimum-necessary-change pushed a commit to minimum-necessary-change/Arduino_STM32 that referenced this issue Sep 16, 2019
.

Signed-off-by: Alexandr Zarubkin <me21@yandex.ru>
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

2 participants