Long timer interrupt periods
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-05-25 01:56 AM
Hello,
I would like to have timer interrupts every 10 minutes for temperature readings. Also, I would like to have opportunity to change this period in the code. How could such long period be implemented? Are there any examples? I am using STM32L011F4 MCU and STM32CubeIDE environment.
Thank you.
- Labels:
-
Interrupt
-
STM32CubeIDE
-
STM32L0 Series
-
TIM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-05-25 03:17 AM
Set the timer's prescaler and ARR so that resulting time is 10 minutes.
If it's not possible with chosen timer, set it to a suitable long period, and in the interrupt count up until the required time elapsed.
Alternatively, chain timers using master-slave connection, use the slave in external clock mode, and set both timers' PSC and ARR to match the required period.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-05-25 03:36 AM
STM32CubeMX clock configuration settings (MCU works at maximum 32 MHz):
Generated Timer init function:
The maximum period I can enter is 65 536 ms (2^16) which is 65.536 seconds. If I enter for example 70 000 then timer interrupts every 5 seconds.
How could I set period to 10 minutes (600 000 ms)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-05-25 03:47 AM
Hi @Indois​ ,
Please refer to the AN3964. This application note describes a method of implementing a simple application for temperature measurement using the STM32L-DISCOVERY and 32L152CDISCOVERY boards. You can start from here and port it to your preferred board. When powered up, the temperature sensor application example first displays a welcome message before immediately displaying the current temperature in degrees Celsius with a 2-second refresh rate.
Best Regards,
Ons.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-05-25 03:49 AM
Set it to 1 minute (60 seconds), and in the interrupt service routine (ISR) count to 10.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-05-25 04:02 AM
But if I use counting, it will act like delay which results in blocking the program. In such case period could not be changed during operation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-05-25 04:37 AM
I am reading temperature from external sensor and would like to have long periods (like 10 minutes) between readings.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-05-25 04:40 AM
Maybe there are other methods to code interrupts for at least every 10 minutes (without timers)? I would like to have opportunity to change period during operation, so delay function could not be used in this case (it blocks the program operation).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-05-25 04:49 AM
Is it possible to 'Set the timer's prescaler and ARR so that resulting time is 10 minutes' in my case when using STM32L011 MCU?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-05-25 03:24 PM
No. Other STM32 do have 32-bit timers, but not the 'L0 family. Cosider the other options I've mentioned.
JW