Skip to main content
gokhannsahin
Associate III
January 14, 2018
Question

STM32L476 RTC with SuperCap

  • January 14, 2018
  • 9 replies
  • 12031 views
Posted on January 14, 2018 at 10:34

Hi everyone,

Should I connect a any series resistor to the super capacitor while using a super capacitor that is 1F 5.5V instead of a battery? Or I can connect directly the capacitor to VBat pin?

#power-backup-supercapacitor-rtc #rtc
This topic has been closed for replies.

9 replies

Szymon PANECKI
Senior III
January 14, 2018
Posted on January 14, 2018 at 10:43

Hello sahin.gokhan,

Voltage range, which can be applied directly to VBAT pin in STM32L4 is 1.55V - 3.6V. Applying higher voltage like 5.5V, which you mentioned, would be out of specification and may lead to MCU damage.

Regards

Szymon
gokhannsahin
Associate III
January 14, 2018
Posted on January 14, 2018 at 11:50

However, at the begining the voltage of capacitor is zero, it will be charged through the VBat pin of mcu. So it will never exceed the higher voltage of 3.6V. Am I wrong?

Szymon PANECKI
Senior III
January 14, 2018
Posted on January 14, 2018 at 12:07

Yes, you are right. I found a webpage, which describes this use case. Here is a

http://embedded-lab.com/blog/stm32s-internal-rtc/

. On this webpage you can find such design:

0690X00000609NIQAY.pngRegards

Szymon

Uwe Bonnes
Chief
January 14, 2018
Posted on January 14, 2018 at 14:35

Why a supercapacitor and not some CR2032? CR2032 will also run a long time, with less hassle and I think is cheaper.

Tesla DeLorean
Guru
January 14, 2018
Posted on January 14, 2018 at 16:53

Shipping stuff with batteries is problematic.

A lot of people won't use batteries in designs due to leakage, shelf life and replaceability/access issues, or assorted bad experiences.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Uwe Bonnes
Chief
January 14, 2018
Posted on January 14, 2018 at 17:02

And supercapacitor never leak?

T J
Senior III
January 14, 2018
Posted on January 14, 2018 at 21:37

Turvey.Clive.002

is right to say we avoid batteries. with the extra handling issues since they are live 24/7

Sahin.Gokhan

is right to ask if a cap would do, great solution

Bonnes.Uwe

is quite right to suggest the CR2032 style lithium. also good solution

Aircraft / delivery are always an issue with batteries. this is a big issue

The best solution is to use a cap, but you must use a high quality cap.

Our simple experiment.

one Friday afternoon,I decided to test this very same question.

I mustered up three different brand caps.

SUNTAN 2000u 25V

Nichon 2200V 10V

some noname rubbish

Leakage test:

Simply I charged them all to 5V and left them on the bench disconnected from everything for the weekend.

Results:

the no name and SUNTAN caps were close to 1 volt. internal resistance has discharged the cap.

the Nichon was still over 4V. to lose 1 V in 2 days, 2000uF is not enough for this question.

So Yes a super cap would work if its a good quality brand. but they suck current hard.

Don't charge it from the pin. I suggest a diode from the 3V reg with 100R in series to reduce the current

Avoid any battery if possible,

I don't think that CR2032 series batteries are a danger to the airline industry since the delivery of current is very low, maximum 10-100mA roughly. depending on size

how many days do you want the cap to hold up the ram ?

In my last design, I used the biggest CR2032 for the RTC, it should run for 10 years without external power.

A. M.
Associate
January 25, 2018
Posted on January 25, 2018 at 13:06

I would never do it (put a battery into a device) to others...

I agree though it may depend on a type of a device.If so, a need of a battery replacement needs to be well known to the user (dedicated enclosure, signs, etc).

Especially if devices go through distribution channels, they also work/stay in various env conditions,

and probably none of us would like to buy a device which just stops working after 2 years for an 'unknown reason'...

I've found such a case (closed within an enclosure, even soldered to pcb) in my temperature controller recently (produced by a well-known brand on the stove market) when doing a repair. I threw it out through a window right away and have replaced it by a super-cap :)

gokhannsahin
Associate III
January 22, 2018
Posted on January 22, 2018 at 06:54

Thank you for your answers.

After charging 3.3V, the systemclockconfig can't pass the LSE ready.

After removing the capacitor in the circuit, then it has passed this condition.

Then, I have connected it the VBAT pin again, it can't pass again.

gokhannsahin
Associate III
January 23, 2018
Posted on January 23, 2018 at 18:10

I haven't found any solution yet, anybody has a solution?

waclawek.jan
Super User
January 23, 2018
Posted on January 23, 2018 at 18:24

 can't pass the LSE ready.

Show code, where does it stuck?

JW

gokhannsahin
Associate III
January 24, 2018
Posted on January 24, 2018 at 10:36

After removing the capacitor, it can pass 

HAL_RCC_OscConfig(&RCC_OscInitStruct), otherwise it can't.

void SystemClock_Config(void)

{

RCC_OscInitTypeDef RCC_OscInitStruct;

RCC_ClkInitTypeDef RCC_ClkInitStruct;

RCC_PeriphCLKInitTypeDef PeriphClkInit;

/**Configure LSE Drive Capability

*/

__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);

/**Initializes the CPU, AHB and APB busses clocks

*/

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE|RCC_OSCILLATORTYPE_MSI;

RCC_OscInitStruct.LSEState = RCC_LSE_ON;

RCC_OscInitStruct.MSIState = RCC_MSI_ON;

RCC_OscInitStruct.MSICalibrationValue = 0;

RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

/**Initializes the CPU, AHB and APB busses clocks

*/

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC;

PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;

if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

/**Enables the Clock Security System

*/

HAL_RCCEx_EnableLSECSS();

/**Configure the main internal regulator output voltage

*/

if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

/**Configure the Systick interrupt time

*/

HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

/**Configure the Systick

*/

HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

/**Enable MSI Auto calibration

*/

HAL_RCCEx_EnableMSIPLLMode();

/* SysTick_IRQn interrupt configuration */

HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

}
Andrew Neil
Super User
January 24, 2018
Posted on January 24, 2018 at 19:09

One big difference between a capacitor and a battery is that a battery has a nominally constant output voltage, whereas a capacitor's terminal voltage drops linearly to zero as it discharges.

Remember: Q = CV ...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
gokhannsahin
Associate III
January 25, 2018
Posted on January 25, 2018 at 21:01

After shorting the pins of capacitor, it can pass LSE ready check. Otherwise,so after the capacitor is charged, it can't pass. I'm so confused. That is a very ridiculous situation. Anybody has a solution or suggetion?

waclawek.jan
Super User
January 25, 2018
Posted on January 25, 2018 at 22:51

 ,

 ,

After shorting the pins of capacitor, it can pass LSE ready check.

Do you mean, you keep shorted the capacitor pins when starting up, or do you release the short before you start up the mcu?

 ,Otherwise,so ,after the capacitor is charged, it can't pass.

Try to remove the capacitor and short the VBAT pin to VCC.

Does it now pass the LSE ready check?

JW

[EDIT] What's the value of RCC_LSE_TIMEOUT_VALUE? Can you increase it?

https://community.st.com/0D70X000006SzwKSAS

 ,
T J
Senior III
January 25, 2018
Posted on January 25, 2018 at 22:52

Your device may be damaged by high current charging the capacitor at any stage in your development.

Have you tried a new processor since the 100R was installed ?

I would adjust that circuit to protect the pin at installation.

3V3  -  diode  -  100R  -  Cap+  -1k -   processor pin

Vasile Guta_Ciucur
Senior
January 26, 2018
Posted on January 26, 2018 at 05:33

See this... 

https://xtronic.org/download/schematic-design/aacircuit-v1-28-ascii/

 

Then you can show the text here as a code to keep the formatting. 

gokhannsahin
Associate III
February 15, 2018
Posted on February 15, 2018 at 07:05

After the capacitor charged, it can't pass systemconfigclock. I tried to short-circuit the pins of supercap and its voltage dropped around 1V. After that, it could pass and charge the capacitor again until its voltage is around 2.3V, but it can't pass again after the restart when its voltage is around 2.3V.

T J
Senior III
February 16, 2018
Posted on February 16, 2018 at 00:43

do you have a resistor between the super cap and the processor pin ?

gokhannsahin
Associate III
February 16, 2018
Posted on February 16, 2018 at 05:31

Yes, there is a resistor is 100R.