cancel
Showing results for 
Search instead for 
Did you mean: 

Timer waking from Sleep mode

Nico3
Senior

MCU is writing data to ext flash once every 15 minute. I have set Timer in interrupt mode with one minute callback and incrementing the flag. In main while loop, the flag is being check . Once flag has reached 15, the MCU writes data to ext flash and sets flag back to zero. 

I am trying MCU to go in sleep mode using WFI. But now the problem is Timer with one minute callback will be waking up MCU every minute. Please suggest. I want this Timer to wakeup MCU only once in 15 minute.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Issamos
Lead II

Hello @Nico3 

I suggest you to set Timer in interrupt mode with 15 minutes callback and forget about the incrementation. That will do the job.

Hope this is helpful for you. If this answers your questions please mark it as best answer to be diffused.

Best regards

II

View solution in original post

9 REPLIES 9
Issamos
Lead II

Hello @Nico3 

I suggest you to set Timer in interrupt mode with 15 minutes callback and forget about the incrementation. That will do the job.

Hope this is helpful for you. If this answers your questions please mark it as best answer to be diffused.

Best regards

II

Sarra.S
ST Employee

Hello @Nico3

I'm not sure why you're using interrupt every 1minute, and don't understand the point of increasing the flag.

The flag is generally used as a boolean variable to know whether a criteria has been met or not, so I wouldn't recommend incrementing a flag. In your case, it's the timer's job to count! So in the callback, you should be handling the interrupt and once the count reaches 15, the flag should be set, 

So you can test on the flag to write to ext flash, or to enter sleep mode 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Nico3
Senior

thanks, I was thinking 15 min setting in Timer not possible. But I am wrong. I will set it.

please let know how to set time for 15 min. clock is 48MHz. pls let know Prescaler and ARR values

I am using STM32F0 series ..having 16bit prescaler 

Hello again

You can use this: Time to count (in second)=(1/48MHz) * (prescaler+1)*(ARR+1).

Best regards.

II

It is not possible to set a 15 minute timer on a 16-bit timer with a timer tick rate of 48 MHz. You can use chained timers instead.

If you feel a post has answered your question, please click "Accept as Solution".

Hello again,

You can also use the TIMER 2 wish has 32-bits ARR register. 

Best regards.

II

Screenshot_2023-09-02-15-37-27-56_e2d5b3f32b79de1d45acd1fad96fbb0f.jpg

Nico3
Senior

Nico3_0-1693722422994.png

please suggest the settings. I set prescaler and ARR but not sure about other setting. i just need to use as basic timer. 

 Hi, your parameters will work fine if you keep them as shown in the picture.

Best regards.

II