STM32F042x RTC without VBAT and LSE - Page 1
Forum section: electronics / general

author: crypton
author_rank: Contributor
timestamp: September 07, 2017, 01:58:17 pm
content: 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 selectedSTM32F042G6U6(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 RTC2) 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:QuoteLets 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 railBUTQuoteBummer.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 modeSleep modeonly and in that configuration [ HSE Bypass = true and PLL=off, 8MHz clock assumption (peripheral disabled)], theconsumption could be up to 0.9mA IDD and 5.5uA IDDA.I can fit only11mAh 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!: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

author: colorado.rob
author_rank: Frequent Contributor
timestamp: September 08, 2017, 03:39:37 am
content: If you are just doing usart to can, why do you need to remain powered on? Just power off when you lose 12v.

author: JPortici
author_rank: Super Contributor
timestamp: September 08, 2017, 06:00:06 am
content: what do you need the RTC for? i don't see a reason why you would

author: crypton
author_rank: Contributor
timestamp: September 08, 2017, 07:23:10 am
content: Aah, my apologies, I probably didn't explain that too well (or at all)RTC - well I need this to keep/count real time when the main supply goes off.There has nothing to do with the communications, I merely tried to explain Why I use that certain package (not like 48 pin package which does have VBAT pin for instance) - size is important and it was dirt cheap for CAN to USART interface.BUT I want to count time for timestamps, like when the main supply goes off and on and for many other logging reasons.I would like to assess those details to see how complicated or more expensive that would become, I do have thought of other alternatives (separate RTC chip, using some other package or other series STM), but I don't want to jump to any other solution without knowing the metrics behind this one.Hope this clarifies. Also added this to my original post.

author: colorado.rob
author_rank: Frequent Contributor
timestamp: September 08, 2017, 12:46:15 pm
content: In that case, use an LSE oscillator. Find an L0, L1 or L4 part. The STM32L432KC should be able to do what need. I just mention that part because it is small and I am familiar with it. No matter what I would use an L part over an F part for new designs. I'd assume that there are L0 parts that will do what you need.

author: krho
author_rank: Regular Contributor
timestamp: September 08, 2017, 07:54:31 pm
content: According to CubeMX there is no L0 part with CAN. I know for certain that L4 parts have it, but it won't be 1$@100pcs

author: crypton
author_rank: Contributor
timestamp: September 19, 2017, 08:40:48 am
content: Quote from: colorado.rob on September 08, 2017, 12:46:15 pmCould you emphasize on Why ? Just because it's later series; it tends to be more available ... ?OK, I'll look into some other series chip, cause separate RTC chip seems to get more costly.

author: lucazader
author_rank: Regular Contributor
timestamp: October 16, 2017, 05:26:23 am
content: You could change to the STM32F042C4 Part.The C4Tx variant is a 48LQFP version of the part you are using. it has pins for LSE and for Vbat for the RTC.It does cost slightly more ($2.12 USD vs $1.77 USD in the mentioned 100pcs volume), But for that extra cost you get to have a much simpler design and easier time software wise. And at the small volumes of 100 devices this trade off is probably quite worth it.If you need a slightly smaller variant then look at the STM32F042C4Ux part it is a 48UFQFPN footprint so it has no leads. so is only 7x7mmAnyway that's my 2c

author: Jeroen3
author_rank: Super Contributor
timestamp: October 16, 2017, 06:03:43 am
content: Or you get like an STM32F072. You can make USB to CAN the size of a thumb drive.It even has "crystal-less USB" if you dare to go that route.