Skip to main content
Visitor II
June 13, 2024
Solved

RTC start time of the init mode

  • June 13, 2024
  • 3 replies
  • 1948 views

Hello,

I've a project with the STM32G030F6 which use the RTC (SYSCLK=64MHz RTCCLK=32768Hz). During the setting of new date/time I enable the INIT mode with:

 

LL_RTC_EnableInitMode (RTC);
while (0u == READ_BIT (RTC->ICSR, RTC_ICSR_INITF))
{
}

 

The runtime of this while() loop is from 42µs to over 60µs. In the refernce manuel is descripe 61µs.

If the measured timing normal? An how can I reduce it?

The application use:

  • RTC
  • WakeUp Timer
  • BackUp Register

Thanks for our help,

Bernd

    This topic has been closed for replies.
    Best answer by waclawek.jan

    Entering the INIT mode takes up to 2 RTCCLK cycles (probably between 1 and 2 RTCCLK cycles, depending on the exact moment when you set the INIT mode in code in respect to the actual RTC clock phase - the processor and RTC clock are mutually asynchronous).

    waclawekjan_0-1718304430008.png

    If RTC clock is the usual 32.768kHz crystal, one RTC period is cca 30.5us, that where the cca 30-60us wait time comes from.

    > An how can I reduce it?

    You can't.

    Why is it a problem? Normally, RTC is set up only rarely, and then it keeps running from a backup battery, without need to go to INIT mode anymore (at least until the battery is exhausted, or until the user decides to change the time).

    JW

    3 replies

    ST Employee
    June 13, 2024

    Hello @bm2 

    You can verify your project optimisation a higher optimization levels can reduce the execution time of the code, just make sure that your compiler optimization settings are appropriate for your project.
    Another solution can help you to reduce the time of code execution is to change clock configuration for your system to ensure that there are no unnecessary wait states or prescalers that could be slowing down the access to the RTC peripheral.

    bm2Author
    Visitor II
    June 13, 2024

    Thank for the answer, but that doesn't answer my question. The problem is the time to synchronise the RCTCLK with the MCU CLK during activation of the INIT mode of the RTC. After reference manual neet this 2x RTCCLK cycles. And that is to slow for my project.

    I use at the moment the optimisation -O0, that is OK for me. I have change the __STATIC_INLINE to __STATIC_FORCEINLINE, so the optimisation is for this not used. And at the moment runs the complete main loop in the RAM, so I have the complete 64MHz performance.

    Super User
    June 13, 2024

    Entering the INIT mode takes up to 2 RTCCLK cycles (probably between 1 and 2 RTCCLK cycles, depending on the exact moment when you set the INIT mode in code in respect to the actual RTC clock phase - the processor and RTC clock are mutually asynchronous).

    waclawekjan_0-1718304430008.png

    If RTC clock is the usual 32.768kHz crystal, one RTC period is cca 30.5us, that where the cca 30-60us wait time comes from.

    > An how can I reduce it?

    You can't.

    Why is it a problem? Normally, RTC is set up only rarely, and then it keeps running from a backup battery, without need to go to INIT mode anymore (at least until the battery is exhausted, or until the user decides to change the time).

    JW

    bm2Author
    Visitor II
    June 13, 2024

    @waclawek.jan I was afraid of it. My customer have start the develpment of the product without clarify the performance of the software. So I have a hard constraint, that after 80µs from receiving of a new date/time the application can make the next step. And at the moment the INIT mode need max. 61µs. So I have only 19µs for the rest and that is to short. So I've think a other peapple have an idee.

    OK, thank for your answer.

    Super User
    June 13, 2024

    > So I have a hard constraint, that after 80µs from receiving of a new date/time the application can make the next step.

    You don't need to wait for the INIT state in a loop. For example, set the INIT bit in RTC, set up a timer to interrupt after a safe time elapses - say 65us - and proceed with setting up the RTC in that interrupt.

    JW

    bm2Author
    Visitor II
    June 14, 2024

    OK, that is not allowed in the application. So I will change the timing reqiurement and hpe that the project lead accept it.