Skip to main content
Associate III
May 14, 2018
Solved

STM32 RTC miliseconds set

  • May 14, 2018
  • 8 replies
  • 2112 views
Posted on May 14, 2018 at 19:40

Hi,

I would like to set the milliseconds in the STM32 RTC, the function hal_rtc_settime doesn't change the milliseconds (subseconds) value.

I tried be setting hrtc->instance->rtc_ssr but it doesnt change its value

Help would be appritiated

Thank you

    This topic has been closed for replies.
    Best answer by waclawek.jan
    Posted on May 14, 2018 at 22:07

    You can't. The subsecond register is read-only.

    You can use the 'shift' feature, though, to manipulate the subsecond register.

    Read the RTC chapter in the reference manual (RM), focus on RTC synchronization chapter and description of the RTC_SHIFTR register.

    JW

    8 replies

    Tesla DeLorean
    Guru
    May 14, 2018
    Posted on May 14, 2018 at 20:08

    Which STM32, there are a few, and the designs of the RTC are different on several families?

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    privenAuthor
    Associate III
    May 14, 2018
    Posted on May 14, 2018 at 20:21

    My bad, STM32L452

    waclawek.jan
    waclawek.janBest answer
    Super User
    May 14, 2018
    Posted on May 14, 2018 at 22:07

    You can't. The subsecond register is read-only.

    You can use the 'shift' feature, though, to manipulate the subsecond register.

    Read the RTC chapter in the reference manual (RM), focus on RTC synchronization chapter and description of the RTC_SHIFTR register.

    JW

    privenAuthor
    Associate III
    May 15, 2018
    Posted on May 15, 2018 at 08:30

    Thank you, I didn't noticed that it was read only

    henry.dick
    Associate II
    May 14, 2018
    Posted on May 14, 2018 at 23:16

    It may help every once in a while to read the datasheet to see how the device you are trying to click-and-program works.

    privenAuthor
    Associate III
    May 15, 2018
    Posted on May 15, 2018 at 08:31

    I have read the datasheet, I have missed the 'r' letter in the register

    Tomohiro Shirane
    Associate II
    June 5, 2018
    Posted on June 05, 2018 at 12:12

    Hello,

    I'm trying to set the milliseconds with STM32 H753-Eval board.

    If I want to set the 400 millisenconds value(for example), should I set the 0x190(=400 decimal) into SUBFS field in RTC_SHIFTR and set the 0x3E7(= 999 decimal) into PREDIV_S field in RTC_PRER ?

    Is my understanding correct ?

    waclawek.jan
    Super User
    June 7, 2018
    Posted on June 07, 2018 at 09:09

    https://community.st.com/0D50X00009XkWK4SAN