cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate an interrupt at an F1 frequency and wakeup MCU at a different F2 lower frequency with RTC

migmel
Senior

Hello guys, I am working with an STM32L071CBT6 MCU. I want to have a cycle of 10 minutes, where MCU works for 1 minute before entering to standby mode during 9 minute.

Using RTC, I want to have an interrupt every 1 minute(60 s); but I don't want the interrupt to wakeup the MCU. I want to use a different RTC event to do so.

Is it possible to implement? Please any suggestion on how to go with this would be appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
migmel
Senior

I have found a solution. I will share it here in case anybody have a similar case:

The main problem was that I only had an LSE crystal, which is used for RTC, but for the rest of timers I had to use inaccurate internal clock source HSI because the lack of an HSE high speed crystal oscillator.

That was the reason I wanted to use RTC to generate the interrupts besides waking up MCU from standby mode(It seems like this is an abomination judging by how few people want to talk about generating interrupts with RTC).

Then I found out that we can use LSE as a clock source for LPTIM. This made my life easier since I got 2 features in one timer: low power and accuracy which is exactly what i was looking for.

So, this is how I solved my problem

Thank you all

View solution in original post

5 REPLIES 5
Diane POMABIA
ST Employee

Hi @migmel​ 

Yes it's possible, To wake up from the Standby mode with an RTC alarm event, it is necessary to:

a) Enable the RTC Alarm interrupt in the RTC_CR register

b) Configure the RTC to generate the RTC alarm.

you can try this example: Projects/NUCLEO-L073RZ/Examples_MIX/PWR/PWR_STANDBY_RTC.

All information concerned on standby mode is resumed on Table 38 of RM0367.

Regards

Diane

migmel
Senior

Hello miss Diane, thank you for your reply.

I have separately done the standby/wakeup cycle with RTC and generated interrupts using another timer(TIM6, which use HSI as clock source). However, in this way, TIM6 lacks of the accuracy and precision I need.

To give you a context, I am using RTC(LSE external crystal) to wakeup the MCU from standby mode, and while the MCU is working, generate the interrupts I need to be perfectly synchronized to RTC.

I thought, what best way if I have RTC also doing the interrupts. Synchronization wouldn't be a problem right?

The main issue I see is, while in standby mode, I don't want RTC interrupts wakeup the MCU, because the interrupt events' frequency are higher than wakeup events' frequency

Diane POMABIA
ST Employee

Hi @migmel​ 

RTC interrupt have not capability to wake up MCU from standby only an external Reset (NRST pin), an IWDG Reset, a rising edge on WKUP pins (WUKP1, WKUP2 or WKUP3), an RTC alarm, a tamper

event, or a time-stamp event detected can wake up MCU from StandBy that have capability to wake up MCU.

Regards

DianeP

Thank you again,

I have used WKUP to wake up MCU.

So, I can used RTC interrupts freely without worry about wake up the MCU when I don't mean to.

One question remains, how can I set an RTC periodic interrupt, lets say every 30 s, without using any EXT Line? I have tried setting RTC global interrupt but nothing seems to happen. Not sure how to set the frequency to do so, or if it is actually doable in this way.

migmel
Senior

I have found a solution. I will share it here in case anybody have a similar case:

The main problem was that I only had an LSE crystal, which is used for RTC, but for the rest of timers I had to use inaccurate internal clock source HSI because the lack of an HSE high speed crystal oscillator.

That was the reason I wanted to use RTC to generate the interrupts besides waking up MCU from standby mode(It seems like this is an abomination judging by how few people want to talk about generating interrupts with RTC).

Then I found out that we can use LSE as a clock source for LPTIM. This made my life easier since I got 2 features in one timer: low power and accuracy which is exactly what i was looking for.

So, this is how I solved my problem

Thank you all