7 years, 6 months ago.

How to select the right clock LSE/LSI

Hi,

how does mbed selects the right RTC? I have made a PCB without LSE (planning to add it in the future). From what i have understood when mbed starts up it checks if it can select LSE external clock and if not it uses the LSI clock, but as i am seeing from these two projects https://developer.mbed.org/users/kenjiArai/code/Nucleo_RTC_Clock_setting/ and https://developer.mbed.org/users/kenjiArai/code/Nucleo_F411RE_SysClk/ the output i get is "no clock". Why is LSI not selected?

My target is to add later on also LSE and when LSE initialisation fails than LSI should be used as fallback. I have searched a little bit and i know that for beeing able to use LSE later on i have to follow this instructions and rebuild mbed https://developer.mbed.org/users/kenjiArai/notebook/nucleo-series-rtc-control-under-power-onoff-and-re/ but i am starting to doubt if this is possible at all since even without LSE incorporated, LSI is not selected.

Does mbed automatically select the best possible RTC on startup? if not how can i initialise the right RTC (LSE or LSI)?

Thnx

1 Answer

7 years, 6 months ago.

Anteo,

Look at targets/TARGET_STM/TARGET_STM32F4/rtc_api.c The RTC_LSI macro controls if the RTC code tries to start up the LSE or LSI clock. I checked targets.json and the RTC_LSI macro is not defined for the NUCLEO_F411RE platform.

Try compiling your program with RTC_LSI defined and I think you may have more success.

Cheers,

Mike

Hi Mike, thnx for the answer. where can i find the targets.json file? You mean the DEVICE_RTC_LSI is not defined there?

posted by anteo c 09 Oct 2016

Not sure you'd be able to modify it in the online compiler. It's in the github repo: ARMmbed/mbed-os.git.

Some other targets have a line like this in their entry in targets.json

"macros": ["RTC_LSI=1"],

posted by Mike Fiore 10 Oct 2016