cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L073 - Init RTC via external clock (PC)

LSchm.1
Associate II

Hi,

My client has an existing circuit which is logging some data (no information given)

Until the logging just has a counter which starts, when a power source is connected.

Now they want to add a real clock to the logging entry, and I saw that the STM32L073 has an included RTC.

Now is the question if there is a easy solution to init the date-time of the RTC via an external "clock source" like a PC over USB.

The client wants something plug and play... so connect the board to the PC, run a "script" to init the RTC. Is that even possible?

Or do you see another possibility?

9 REPLIES 9

It might be possible to develop a script e.g. using gdb/python, which would initialize the RTC through the debugging interface if it's available (i.e. target is not locked to level 2, SWD header is available). I know of nothing out of the shelf though.

Is the target permanently (battery) powered?

JW

LSchm.1
Associate II

Okay, thank you! Do you see an easier way? So I can see if it would be feasible for my to work it out.

The target target has an external power source, but unfortunately there is no possibility for a backup battery for the RTC, that's why we need the easy init posibility

LS

> So I can see if it would be feasible for my to work it out.

Sorry but I have no idea what is feasible for you.

The standard way is to integrate this into the firmware. So, if you already have established some form of communication with PC, then add to protocol an "Update RTC" feature and implement it in both the mcu and the PC side.

For me, this is far harder way than what I've described above, but YMMV.

JW

LSchm.1
Associate II

hi,

so i will get access to the firmware. Just doesn’t have it now. That’s why it was a more general question how to do it.

ok thank you anyway - for the easier and harder way

You can also download a stub firmware which does nothing just communicates with PC and updates the RTC, then overwrite it with the production firmware again.

With a bit of intelhex editing, that stub firmware might be made to contain the current time at the moment of uploading, eliminating the need for the communication part on both the PC and device side. This sounds to me as fairly easy, too.

JW

is there a firmware like this already existing to your knowledge? Just looked at the RTC examples of the STM32 series but couldn't find something like this.

Would be nice to have a look at it!

What, setting up the RTC? But that's an almost trivial exercise, simply follow what's written in the RM, backup-domain register in RCC to enable LSE (if any) and select RTC clock, and then the RTC chapter...

Sure there are examples in Cube...

JW

Microsoft removed a lot of the auto-run type stuff as it was a vector for viruses, etc.

You could pretend to be a USB MSC, and perhaps the system would try to write a test file to probe the speed, and push data file a file-system timestamp you could retrieve. Would be fairly involved.

If you are a VCP/CDC device you could write PC side software to open a COM port, and send a date/time string.

Problem generally here is that you have to own the software on both sides of the transaction, and the RTC clock setting examples are usually pretty simple and banal.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Okay, well I'm not concerned about the Microsoft limitation, would have also different Hosts/PC around.

That with the VCP/CDC sounds promising. As mentioned before, I will own both sides. And if I may ask, if it's that simple; is there an example for this? Couldn't find anything fitting my problem.