cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 RTC resets itself

nikola2
Associate II
Posted on August 04, 2017 at 08:06

Hello,

I have troubles with the STM32L467. I am using the RTC without any extra settings like alarm or tamper. I have set the time via STM32Cube and at some points in the code the chip reads out the time.

My problem is that after some time the time is reset without making any reset to the chip.

Here an output:

First output:

            sDate.Year = 17

sDate.Month = 7

sDate.Date = 10

sTime.Hours = 13

sTime.Minutes = 17

sTime.Seconds = 10

� some time passes by �

Second output:

sDate.Year = 0

sDate.Month = 0

sDate.Date = 0

sTime.Hours = 0

sTime.Minutes = 0

sTime.Seconds = 0

I have found in the errata sheet that there are some troubles with the tamper detection. That�s why I tried the following code:

    hrtc.Instance->TAMPCR |= (1 << 23); // TAMP3NOERASE (Bit 23)

                HAL_Delay(5);

                hrtc.Instance->TAMPCR &= ~(1 << 5);

                HAL_Delay(5);

                hrtc.Instance->TAMPCR |= (1 << 20); // TAMP2NOERASE (Bit 20)

                HAL_Delay(5);

                hrtc.Instance->TAMPCR &= ~(1 << 3);

                HAL_Delay(5);

                hrtc.Instance->TAMPCR |= (1 << 17); // TAMP1NOERASE (Bit 17)

                HAL_Delay(5);

                hrtc.Instance->TAMPCR &= ~(1 << 0);

                HAL_Delay(5);

But it didn�t work. Is there something that I am missing?

Many thanks in advance!

Nikola

#errata #rtc #stm32l4 #stm32l476 #issue
3 REPLIES 3
Posted on August 04, 2017 at 09:39

Is VBAT properly connected? Check also all ground connections; by 'check' I don't mean 'look at the schematics' but 'measure direcly on the pins'.

Is DBP bit in the PWR_CR1 register properly managed, i.e. kept at zero at all times except the moments when access to backup domain is absolutely necessary?

Is there any code accessing any parts of RCC_BDCR?

JW

Posted on August 08, 2017 at 00:10

Thank you for the tips!

But nothing helped. I could locate the part of the code were this error must occur. But I cannot understand what is causing it.

This part of the code is just reading out the ADC, filtering with the arm_fir_f32 lib and then calculating some stuff. There are no register accesses. Only variables and arrays…

Cheers,

Nikola

Posted on August 08, 2017 at 01:08

Do you use some of the low-power modes?

Do you read the RTC registers directly or through some Cube-style 'accessor struct'? If the latter, can't that struct be corrupted? If you run a debugger, look directly at the RTC registers.

JW