Hello!
Attention: this post might need extended time to delve into.
Perhaps anyone of you has experience implementing STM32's RTC, that Doesn't have low frequency crystal option?
I want to keep logging real time clock when the main supply (12V) is turned off - nothing else (no comms, no bells and whistles).I do have some other alternatives (such as separate RTC chip, or another package or family of STM), but I don't want to jump to any other solution without knowing how much more complex or expensive the solution becomes using this STM. So I would like to understand the metrics and also learn something along the way, when things are limited.
I have currently selected
STM32F042G6U6 (UFQFPN28) which doesn't have dedicated VBAT pin for RTC use - thus also no LSE crystal possibility.
I am using this particular STM and package merely because I'm using it only as a CAN tranceiver (to USART), it's small and cheap!
Absence of VBAT and LSE leads to many related issues, for which I have some ways to address them, but I am not sure about some details.
In general:1) I can only use HSE for the RTC
2) I have to make external circuitry to power the chip from coin cell when main power is off.
3) Since I use HSE, I can only use Sleep Mode as the low power mode (otherwise the crystal won't work) and thus power consumption is rather high to maintain decent life time.
So all in all I want to confirm my assumptions and worries and maybe I have to look for another STM (f.i with 48pins that has VBAT)...
In more detail:1) I haven't been able to figure out, is it better to use as low frequency crystal as possible (4MHz) or the highest possible (32MHz) to get 1Hz RTC frequency?a) This STM has fixed prescaler, until it becomes RTC_CLK - I understand I can then further divide it with registry values.
In appnote AN3371:
"Increasing the value of the asynchronous prescaler reduces the power consumption". So it MIGHT be better to use some higher frequency crystal with low load capacitance requirements, so I could divide it first hand with higher prescaler...? Then again, driving the crystal faster should consume more..
Lets say Asynch predivider set to 125 (it is very high so, consumption should be low) and Synchronous predivider to 1000.
Would this be correct ?
2) Powering the chip, when main supply is off.There are several ways. In general I would be using diode OR-ing from 3V3 rail and measuring my main 12V supply from resistor divider to either get interrupt from sudden power loss or measure it via ADC if it get's too low so STM can do last minute operations - like switch to coin cell backup power.
But for actual wiring I am not sure:a) Can I just get away with powering VDD pin only?- It seems that the RTC and backup registers are connected only through this rail. So I should be able to get away powering only this rail
BUT
"The VDDA voltage level must be always greater or equal to the VDD voltage level and must be established first.."
Bummer.
So am I correct that I still have to power VDD ?I would definitely not power VDDIO2 from the coin cell (I think I can decrease consumption with that).
3) I can run the RTC in low power mode
Sleep mode only and in that configuration [ HSE Bypass = true and PLL=off, 8MHz clock assumption (peripheral disabled)], the
consumption could be up to 0.9mA IDD and 5.5uA IDDA.I can fit only
11mAh coin cell, thus leaving me around like what... 11000uAh / 905.5uA = 12h of expected lifetime.
I currently don't see any other possble way to decrease this consumption with HSE RTC....So all in all I want to confirm my assumptions and worries and maybe I have to look for another STM (f.i with 48pins that has VBAT)...Thank you, if you're reached so far. Any comments would be very appreciated! [1]:
http://www.st.com/content/ccc/resource/technical/document/datasheet/52/ad/d0/80/e6/be/40/ad/DM00105814.pdf/files/DM00105814.pdf/jcr:content/translations/en.DM00105814.pdf