2023-11-20 09:23 PM
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.
Solved! Go to Solution.
2023-11-22 10:08 PM
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.
2023-11-20 09:46 PM - edited 2023-11-20 09:55 PM
Hello @raisa_razak and welcome to the ST Community :smiling_face_with_smiling_eyes:.
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.
2023-11-20 09:52 PM
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.
2023-11-20 09:55 PM - edited 2023-11-20 09:57 PM
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.
2023-11-20 10:03 PM - edited 2023-11-20 10:49 PM
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.
2023-11-20 10:30 PM
I am getting the PSCms -1 = 4.8. It will not work right?
[since my PSCs = 4799 (for 1sec)]
2023-11-20 10:53 PM - edited 2023-11-20 10:55 PM
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.
2023-11-20 10:57 PM
Yeah I tried like that but it is not working like 1ms timer.
2023-11-20 11:26 PM
you just change ARR from 9 to 9999, it should work correctly.
2023-11-20 11:30 PM
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.