Skip to main content
tetj
Associate II
April 24, 2014
Question

STM32F1 Clock/Calendar BUG

  • April 24, 2014
  • 4 replies
  • 938 views
Posted on April 24, 2014 at 15:08

Hello, I noticed a problem in the software implementation of STM32F1 's clock/calendar. If the device is switched off for a long time (>= 255 days) it will enter infinite loop inside  CheckForDaysElapsed() (which is inside RTC_Configuration() function) because the for(;;) loop variable is only 8bits in size. I replaced several microcontrollers before finding this as I thought they were faulty.

Has anyone encountered this issue ?

    This topic has been closed for replies.

    4 replies

    Amel NASRI
    Technical Moderator
    April 28, 2014
    Posted on April 28, 2014 at 16:03

    Which software implementation are you speaking about?

    -Mayla-

    To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.
    tetj
    tetjAuthor
    Associate II
    April 28, 2014
    Posted on April 28, 2014 at 22:08

    The one from

    http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/PF257855

    . It is for STM32F1 series only.

    Tesla DeLorean
    Guru
    April 28, 2014
    Posted on April 28, 2014 at 23:21

    Yes, there appear to be issues with that, and frankly I don't care for that approach to calendering. I built a scheme using a 32-bit second value from epoch (136 years), and computed the date/time when required. A linear view of time is best expressed in seconds, not human centric dates.

    Rule#1 For Third-Party calendering solutions : They are usually broken in subtle ways, and the time required to validate them would exceed the time to write correctly from scratch.
    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    tetj
    tetjAuthor
    Associate II
    April 28, 2014
    Posted on April 29, 2014 at 00:05

    Couldn't agree more Clive, good thing I only used the lib for one project. I then switched to UNIX time format too. As you said it is pretty straightforward.