cancel
Showing results for 
Search instead for 
Did you mean: 

Timer Configuration

raisa_razak
Associate III

Hi, I got a small problem while configuring timers in NUCLEO-F072RB board. I want to configure one timer for 1ms and another for 1sec, Could you please explain me how to set the prescaler and period(ARR) values of both the timers. My HCLK is 48MHz.

1 ACCEPTED SOLUTION

Accepted Solutions

Thank you all for the replies.

I figured out my problem. Except for the more recent dual core MCUs, most STM32 are limited to running only one thing at a time, so i am trying to use FreeRTOS or similar to have the system switch between tasks as needed.

View solution in original post

18 REPLIES 18
STTwo-32
ST Employee

Hello @raisa_razak and welcome to the ST Community 😊.

You will fin here everything you are looking for with détails.

Best Regards.

STTwo-32

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.

Thankyou for your reply.

Yeah i tried this one for 1sec interrupt in one timer and it is working but I want to configure the 2nd timer for 1ms interrupt, there it is not working with this calculation.

Tinnagit
Senior II

you can read it in page 81 - an4776-generalpurpose-timer-cookbook-for-stm32-microcontrollers-stmicroelectronics.pdf

t = ((PreScalar+1)*(ARR+1))/Tclk

but If you have don't use RTC to alarm something, You should use Alarm-A and Alarm-B to trigger every sec and millisec.

To make it easier, you Can keep the same parameters as for the 1s timer and use PSCms-1=(1/1000)*(PSCs+1)  

PSCms: prescaler for 1ms.

PSCs: prescaler for 1s.

Or do the samething with ARR.

Best Regards.

STTwo-32 

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.

I am getting the PSCms -1 = 4.8. It will not work right?

[since my PSCs = 4799 (for 1sec)]

Than use ARR=9 and keep PSC to 4799.

Best Regards.

STTwo-32

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.

Yeah I tried like that but it is not working like 1ms timer.

 

Tinnagit
Senior II

you just change ARR from 9 to 9999, it should work correctly.

Then it is working like a 1sec timer. 

For my 1sec timer i put prescaler as 4799 and ARR as 9999 as per the calculation and it is working properly. But the problem is with the configuration of 1ms timer.