cancel
Showing results for 
Search instead for 
Did you mean: 

Switch over RTC from LSE to LSI while running

SPate.7
Associate

Hello all!

Using STM32L433, RTC is initialized with LSE, works fine.

In run, I want to switch to LSI and do certain steps and want to get back to LSE. What is the way to switch over RTC source LSE<->LSI ? I read some thing about backup domain. Please give some hint.

Thanks!

Sanket

3 REPLIES 3

0690X000006CsnUQAS.png

It means, that you can't simply switch sources of RTC. The only way would be to read the current time/date, reset backup domain (see BDRST in the same register), if switching from LSI to LSE then start LSE, switch to the required clock source, and set up RTC completely again.

You'll lose some of the timing precision, of course; but LSI is so imprecise that this probably wouldn't really matter.

Maybe you want to tell us why do you want to do this switchover, and maybe there are better ways how to solve the problem.

JW

SPate.7
Associate

Thank you Jan Waclawek!

I am using USBMSC. Whenever I connect my custom PCB with computer USB, RTC stops working (checked by toggling port pin at every 1sec). However, this happens in some of the PCBs only. I verified that if RTC made run with LSI, it never stops working when USB is connected. So, I want to switch over to the LSI from LSE when USB interrupt is detected. Will do require things and then will get back to LSE.

Surprisingly, I still find 1.1V and 0.4V across XTAL pins, whenever RTC stops working!! I am wondering as differential voltages are coming, whether LSE is running!?

This clock switching may not be the proper solution, but as of now I cannot find any better. Would appreciate your suggestion.

Thanks!

Sanket

Try to mitigate the real problem rather than working around in this way. There is no reason for the RTC to stop working when connecting USB. You may have problems with power and/or grounding. Try to connect a laptop with no other cable connected.

JW