Skip to main content
KDemi.1
Associate
July 24, 2020
Question

Hi all, I have a stm32f103 and want to put it into stop mode (it works), but I have to wake it up again after 30 ms. can I do that with the RTC alarm.

  • July 24, 2020
  • 4 replies
  • 986 views

in the user manual: Seconds interrupt, for generating a periodic interrupt signal with a programmable.

but it is not as it is with the RTC alarm

Best Regards

Kadir

This topic has been closed for replies.

4 replies

Danish1
Lead III
July 24, 2020

30 ms is quite short for stop mode. I would be tempted to put it to sleep (leave the clocks running) for that.

But if you need stop mode, my comments are:

stm32f103 is quite old, and its RTC is different from the one you will find in most stm32 microcontrollers.

What you might be able to do with the RTC is use the overflow interrupt. You can load RTC_CNT with a value close to overflow (e.g. 0xffffffff) and it will count up. When it overflows to 0x0000000 then you get an interrupt.

How often do these counts occur? At the frequency of the RTC - typically a 32.768 kHz crystal. So one would only be able to generate an interrupt every 30.5 ms. And there would be no way to do any finer control - those counts happen when they happen. If you enter stop mode just before a count is due, you'll get woken up very quickly.

If you want stop mode because you need extremely low power, you might be better off using one of the more modern stm32l family. They are much lower power, and likely to remain available for much longer than stm32f103.

Hope this helps,

Danish

KDemi.1
KDemi.1Author
Associate
July 24, 2020

Thank you Danish for the fast feedback.

The count should run all the time, i.e. switch off every 30 ms, then start again after 30 ms.

This is for a low power energy model and something is done every 30 ms. do you think this is feasible?

Best Regards

Kadir

Danish1
Lead III
July 24, 2020

It won't be 30.0 ms. It will be 30.5176 ms if you're using a 32.768 kHz crystal.

But if you're using the LSI oscillator rather than LSE, it might be anywhere between 16 ms and 34 ms. And will probably suffer from jitter as well as drift with temperature.

If you can live with that, then yes it is feasible.

KDemi.1
KDemi.1Author
Associate
July 24, 2020

thanks, that helped me a lot