Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32L4 enter critical section for a long time #7827

Closed
kevinong0108 opened this issue Aug 19, 2018 · 6 comments
Closed

STM32L4 enter critical section for a long time #7827

kevinong0108 opened this issue Aug 19, 2018 · 6 comments

Comments

@kevinong0108
Copy link
Contributor

Description

set_time() will occur system enter critical section for a long time (around 1 second) when DEVICE_LPTICKER is enabled on STM32L476.

The following code is in rtc_api.c, there will spend time to wait in enter critical section.
Why need this part?

#if DEVICE_LPTICKER && !MBED_CONF_TARGET_LPTICKER_LPTIM
    while (Read_SubSeconds != (RTC->SSR)) {
    }
#endif /* DEVICE_LPTICKER && !MBED_CONF_TARGET_LPTICKER_LPTIM */

I am not sure how about other series.

Issue request type

[X] Question
[ ] Enhancement
[ ] Bug

@ciarmcom
Copy link
Member

ARM Internal Ref: MBOTRIAGE-1532

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 20, 2018

@ARMmbed/team-st-mcd Please review

@LMESTM
Copy link
Contributor

LMESTM commented Aug 20, 2018

@kevinong0108 Thanks for the question.

This code is active is the below case
#if DEVICE_LPTICKER && !MBED_CONF_TARGET_LPTICKER_LPTIM
which applies to devices who want to use LPTICKER feature but do not have a LPTIM HW.

In this configuration, the RTC hardware will be used for 2 purposes: For the standard time & date management, but also the sub-second part is used as Low Power Ticker which will be used for scheduling purposes. I think the code tries to sync the new time with and the ticker to avoid mis-alignments of some low period that have been scheduler. But maybe there is a side effect that needs to be analyzed. My colleague who wrote this code is out of office and will be back in 2 weeks, I'd prefer to wait for his return so that he can confirm .

In the meantime, when it comes to STM32L4, I think that the LPTIM HW is available so that I would advise to also add the below config to your device. this should avoid that your L4 device is impacted by this side effect.

        "lpticker_lptim": {
            "help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
            "value": 1
        }

Br
Laurent

@mattbrown015
Copy link
Contributor

There's a discussion about the difference between using LPTIM and the RTC on the STM32L4 here, How to Achieve Long Periods of Deep Sleep on STM32 #7156.

In summary, on the STM32L4 the LPTIM is only 16-bits and therefore it will only achieve a deepsleep of a few seconds. The RTC has to be used in order to achieve longer periods of deepsleep.

The code highlighted is important to me because I have enabled tickless in RTC mode and I use settime(). Having said that, I haven't noticed it causing a problem in practice. :-)

@kevinong0108
Copy link
Contributor Author

@LMESTM and @mattbrown015 Thanks for your reply, fully understand :)

@bcostm
Copy link
Contributor

bcostm commented Aug 30, 2018

Hi,
Can you please close this issue if all questions have been answered ? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants