[STM32L476DISCO] RTC not ticking

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
User avatar
roland_vs
Posts: 83
Joined: Tue Dec 08, 2015 8:28 pm
Location: Netherlands
Contact:

[STM32L476DISCO] RTC not ticking

Post by roland_vs » Tue Sep 26, 2017 12:37 pm

Dear all,

Anyone experienced the fact that the RTC is not running?

import pyb
pyb.RTC().datetime() should change every time you issue this command.
Also setting the clock takes about a second or so before the prompt returns, but no changes to the registers at all.

The default time is stuck at (2000,1,1,0,0,0,0,0,0), so the default that is setup in the code rtc.c is not copied to the RTC.

Testing the same code (latest mpy) on the pyb10 and other F4 versions works fine, however the L4 versions do not.

Before diving into the possible problem, does anyone had the same problem and already fixed it?


Regards,

Roland

User avatar
pythoncoder
Posts: 3209
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: [STM32L476DISCO] RTC not ticking

Post by pythoncoder » Wed Sep 27, 2017 7:13 am

I have seen that on the Pyboard when I've inadvertently stopped the 32KHz oscillator. This can occur if you forget that it's still running when the board is powered down but fitted with a backup cell - touching the crystal or its capacitors can stop the oscillator.
Peter Hinch

User avatar
roland_vs
Posts: 83
Joined: Tue Dec 08, 2015 8:28 pm
Location: Netherlands
Contact:

Re: [STM32L476DISCO] RTC not ticking

Post by roland_vs » Wed Sep 27, 2017 9:52 am

@pythoncoder Dear Peter,

Indeed I noticed when I put my finger on the capacitors next to the 32kHz Oscillator REPL via the USB doesn't respond, and removing the finger everything works again.

I tested the L476 port on the original STM32L476DISCO (reference) and two boards of my own making. They all have the same problem: RTC not running. All of the boards I have with the F4 series (405, 407, 439) work OK. That may lead to the conclusion that it is a problem with the L476, but it would be nice if there is anyone with an L476 based board to verify it...

Also I assume that writing a set of new values like (2017,9,27,11,12,3,0,0) should at least copy the values to the RTC registers even when the clock is not ticking...

User avatar
roland_vs
Posts: 83
Joined: Tue Dec 08, 2015 8:28 pm
Location: Netherlands
Contact:

Re: [STM32L476DISCO] RTC not ticking

Post by roland_vs » Tue Nov 28, 2017 3:03 pm

Update:

I have updated the `mpconfigboard.h` of my own board variant and the `STM32L476DISCO` by adding the external oscillator to be enabled:

#define MICROPY_HW_RTC_USE_LSE (1)

The RTC will run now. This does not explain why it's not running using `lsi` or `msi` mode, but at least my hardware is ticking....

User avatar
badi
Posts: 49
Joined: Mon Aug 10, 2015 2:18 pm
Location: Bern, Switzerland

Re: [STM32L476DISCO] RTC not ticking

Post by badi » Sun Dec 10, 2017 2:05 pm

The #define fix does not work on my board.

However after a longer debug session I discovered, that calling the init() from MicroPython on the RTC starts the clock - which is not needed on the F4 - even without the #define in the header file.

If you look on the clock-tree of the L4 (eg. CubeMx or reference manual) you will notice, that only the LSI or the LSE can feed the clock for the RTC. With the #define i assume that the RTC runs on the more precise external crystal.

I do not know yet, why this init function exists a when it is or should be called.

Tobias
badi

Niallp
Posts: 20
Joined: Sun Nov 29, 2015 10:25 pm
Location: Pender Island, BC

Re: [STM32L476DISCO] RTC not ticking

Post by Niallp » Fri Jan 25, 2019 8:18 pm

Many thanks for pointing out the init() function and that it needs to be called explicitly ... I couldn't figure out why the clock wasn't running on my board (based on the Nucleo-L476RG port) unless I had already run some other code (using CubeMX) that had initialized access to the RTC backup registers.

Need to dig deeper to understand why the L4 and Fx ports operated differently, haven't found it in rtc.c yet.

Post Reply