Skip to main content
tm3341
Associate III
December 3, 2014
Question

RTC December read problem

  • December 3, 2014
  • 3 replies
  • 596 views
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.
    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    December 3, 2014
    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 VenmoUp vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Guru
    December 3, 2014
    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 VenmoUp vote any posts that you find helpful, it shows what's working..
    tm3341
    tm3341Author
    Associate III
    December 3, 2014
    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.