2023-11-06 09:05 PM
Hi community,
I'm having a STM32F407VET6 PCB board where VBAT is connected to a 10 uF decoupling capacitor [Instead of recommended 100 nF capacitor].
in order to achieve some backup time when both the coin cell and 3.3V are not connected.
My RTC is working fine when a coin-cell or 3.3V supply is available in VBAT. But when I remove the coin cell while performing a power cycle, I'm facing some issues, as listed below.
[Note: RTC is initialized properly with the time 2023-11-07T08:31:20Z [YYYY-MM-DDTHH:MM:SSZ]]
[Note: Coin cell is removed from the board]
Case | Power cycle duration | Voltage level in VBAT Decoupling Capacitor | Result | Observation |
1 | 7 Seconds | 3.16V to 0.86V | Working fine | RTC Accumulated entire power cycle duration properly |
2 | 8 Seconds | 3.15V to 0.77V | RTC Init failed - goes to error handler mode | RTC Accumulated entire power cycle duration properly |
3 | 30 Seconds | 3.16V to 0.46V | RTC Init failed - goes to error handler mode | RTC Accumulated only first 12 Seconds of the power cycle |
4 | 5 minutes | 3.16V to 0.15V | RTC Init failed - goes to error handler mode | RTC Accumulated only first 12 Seconds of the power cycle |
5 | 6 minutes | 3.16V to 0.10V | RTC de-initialized | RTC de-initialized doesn't goes to error handler mode |
The issue is RTC is working fine till 7 seconds with the backup of decoupling capacitor, after that it goes to error handler mode but still accumulating time for first 12 seconds of power cycle [8 Seconds to 5 minutes].
After 6 minutes it de-initialized RTC and doesn't goes to error handler mode. I wanted to de-initialize RTC after the RTC accumulates the first 12 seconds of power cycle in order to avoid error handler mode.
Anyone please explain does the decoupling capacitor affects this behavior in hardware perspective or should I need to use any register to tackle this issue in software perspective.
2023-11-06 10:31 PM
10 µF just isn't a real battery, as you can see from your own tests.
Try at least 100 µF (6V3) if you want to keep standard caps, otherwise try a supercap.
2023-11-06 10:44 PM
Hi LCE,
Thanks for the response. I also wanted to know why the RTC goes to error handler mode after a particular power cycle duration [7 seconds]. Does increasing the capacitance fix the error handling issue?
2023-11-06 10:47 PM
I don't know. What does the datasheet say about the minimum required voltage? 0.86 V is quite low.
2023-11-06 11:03 PM
2023-11-06 11:11 PM
You are probably hitting VBAT brownout, ie. incomplete/faulty reset.
Software ends up in error handler probably due to bug in software, which does not anticipate this state. If you are using Cube or similar "library", you may want to avoid it and write your own.
JW
2023-11-06 11:37 PM
Gotcha, Thanks Evangelist!
2023-11-07 02:17 AM
> Vbat as ranging from 1.65 to 3.6 V
Well, looks like 0.86 V is much too low.
I guess even the 100 µF will not be enough for more than a few seconds.
2023-12-08 08:35 PM
Hi JW
I am using the STM32 Cube IDE to generate code. In that RTC goes into error state based on the above circumstances at RTC_EnterInitMode. I will write the generated function below
HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef *hrtc)
{
uint32_t tickstart = 0U;
HAL_StatusTypeDef status = HAL_OK;
LOG_DEBUG("Entered RTC Init mode - Line Number %s->%s:%d\n", __FILE__, __FUNCTION__, __LINE__);
/* Check that Initialization mode is not already set */
if (READ_BIT(hrtc->Instance->ISR, RTC_ISR_INITF) == 0U)
{
/* Set INIT bit to enter Initialization mode */
SET_BIT(hrtc->Instance->ISR, RTC_ISR_INIT);
/* Get tick */
tickstart = HAL_GetTick();
/* Wait till RTC is in INIT state and if timeout is reached exit */
while ((READ_BIT(hrtc->Instance->ISR, RTC_ISR_INITF) == 0U) && (status != HAL_ERROR))
{
if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
{
/* Set RTC state */
LOG_DEBUG("RTC goes to error state IN RTC_ENTER_INIT_MODE - Line Number %s->%s:%d\n", __FILE__, __FUNCTION__, __LINE__);
hrtc->State = HAL_RTC_STATE_ERROR;
status = HAL_ERROR;
}
}
}
return status;
}
2023-12-09 12:16 AM
This is probably just a consequence, and you need to devise a check for the brownout and reset backup domain explicitly before attempting to set anything in it, including LSE clock.
I don't use Cube/HAL, and I don't use a capacitor on VBAT, so don't have personal experience with this particular issue.
JW