cancel
Showing results for 
Search instead for 
Did you mean: 

RTC December read problem

tm3341
Associate II
Posted on December 03, 2014 at 19:49

Hi.

I have my RTC lib, which is working just fine except one thing.

When december arrived, my RTC date register reads 0 as date except 12.

I have read with RTC_GetDate(RTC_Format_BIN,..) and Month is set to 0.

Why is that?

In the stm32f4xx_rcc.h is define for January set to 0x01 and for December to 0x12 (in BCD) so I assume that december is 12 and january is 1 in registers.

I have no idea, please help about that strange error.
3 REPLIES 3
Posted on December 03, 2014 at 19:56

It rolled over to zero? Access to PWR/BKP enabled?

If you write 0x12 BCD do you get 0x12 BCD back?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on December 03, 2014 at 21:00

RTC seems to rollover fine here

ClockDiagnostic
SYS:8000000 H:8000000, P1:8000000, P2:8000000
LSI:34482, LSE:0
HSE Source
LSI On
LSI Ready
LSE On
LSE Not Ready
LSE ByPass Off
RTC Clock Enabled
RTC Clock Source LSI
23:59:57 30/11/14
23:59:58 30/11/14
23:59:59 30/11/14
00:00:00 01/12/14
00:00:01 01/12/14
00:00:02 01/12/14
00:00:03 01/12/14
00:00:04 01/12/14
00:00:05 01/12/14
00:00:06 01/12/14

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
tm3341
Associate II
Posted on December 03, 2014 at 22:17

Hi.

Thanks for replay.

I found the problem after connecting debugger on board. The problem was because After read from RTC, I also called function to calculate unix timestamp in seconds. 

In this functions I've dones this: data->month = data->month % 12; and when december (12) result was 0.

Now, it is working ok.