boards/nucleo-l1: use LSI as default RTC clock#6504
boards/nucleo-l1: use LSI as default RTC clock#6504haukepetersen wants to merge 4 commits intoRIOT-OS:masterfrom
Conversation
|
The problem of the LSI is its accuracy. But it works if application does not require accuracy for long periods I guess. However, I took a new look to the RTC application note. It seems that the stm32l1 LSI is a 37kHz oscillator, then the prescaler register needs to be adapted. (AN3371, part 1.1.2, page 9) |
|
I'm on current master (includes #6499) without this PR running tests/periph_rtc. The output looks as expected: So does with this PR.. Do we actually need it? |
cpu/stm32_common/periph/rtc.c
Outdated
| #else | ||
| /* Enable the LSI clock */ | ||
| RCC->CSR = RCC_CSR_LSION; | ||
| while (!(RCC->CSR & RCC_CSR_LSIRDY)) {} |
There was a problem hiding this comment.
For a F0 this didn't work. The LSI is off after each reboot but (RCC->BDCR & RCC_BDCR_RTCEN) == 1 so rtc_poweron() isn't called. Adding these 2 lines to clk_init() in cpu.c solved it for me
There was a problem hiding this comment.
will look into this.
|
@PeterKietzmann: probably your board is equipped with an external low-speed oscillator, so it works on master. But mine isn't, so it doesnt work on master -> ergo: this PR is needed. |
|
I proposed some more fixes in haukepetersen#37
But I don't really like the LSI as default... |
|
Confirmed that it works for nucleo-l152, but it breaks on nucleo-f091. Should this bug be postponed? |
|
I'd say yes. The release should go out tomorrow. Testing has mostly passed and I already added this issue to known issues in the preliminary (still invisible) release notes. Will take care of all 2017.01 labelled PRs tomorrow. |
|
@kYc0o weird, I tested on a nucleo-f091 here and it worked :/ Anyway, I agree it should be postponed. |
|
Well, mine gets stuck in setting the clock: 2017-02-02 12:42:52,413 - INFO # main(): This is RIOT! (Version: 2017.04-devel-8-gd1df5-snake.lan-pr/stm32l_lsi)
2017-02-02 12:42:52,413 - INFO #
2017-02-02 12:42:52,415 - INFO # RIOT RTC low-level driver test
2017-02-02 12:42:52,420 - INFO # This test will display 'Alarm' in 10 seconds
2017-02-02 12:42:52,420 - INFO #
2017-02-02 12:42:52,421 - INFO # Initializing the RTC driver
2017-02-02 12:42:52,425 - INFO # Setting clock to 2011-12-13 14:15:15Same question: Which revision of nucleo-f091 do you have? does it have an external oscillator? |
|
My nucleo-f091 has an external oscillator. I've just retested on it (with On a nucleo-f042 without LSE, it works fine. |
|
This is not a RTC issue, this is a timer configuration issue. It get stuck in |
|
Seems related to #6494 |
|
@haukepetersen can you squash and optionally rebase to include #6494 ? Then I think this is ready. |
|
Ping @haukepetersen |
|
any update on this one @haukepetersen ? |
|
Yes, that makes sense. One more reason to handle the clock LS(I/E) clock only at one place in the code. |
|
I am looking into refining the RTT/RTC interfaces right now, and will in the same run look into a way to handle this for all STM32 CPUs |
|
Can we merge this one for this release? I think that as long as the bug is solved, we can wait for the rework on this interface and merge it for the next release. AFAIK this PR is a working state and can be merged asap (besides the need of squash). |
|
nope, won't merge this in the current state. Have a far better solution to the problem now (based on some clock initialization restructuring as done in #6907), so I will adapt this PR accordingly. |
|
And you think we can get it for the release? That's only my point, that is broken and it will stay broken for this release... |
|
the solution as in this PR is sub-optimal, found something better by now: the |
3fa0951 to
cf0da44
Compare
|
pushed an update to the rtc driver using the stmclk interface -> much easier to the eye... But as said: all WIP as of now... |
|
closing in favor of #7504 |
|
#8024 led me here... So, I propose to enable the internal oscillator only for the nucleo-l152 board, since anyways nobody will use it for accurate RTC and all stm32l152 have LSI. Should I open a PR for that small change? I tested it on a board with external oscillator and works correctly with LSI set. |
fixes #6502
rebased on #6499 (needed for testing)seems like not all
nucleo-l1boards have an external low-speed oscillator (LSE) attached. So I propose to make it configurable in the board's periph_conf and choose the LSI (internal low-speed oscillator) per default.