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.

18 REPLIES 18

So you can use same configuration with timer for 1ms and change ARR to 9 and it's trigger every 1ms.

Tried, but not getting correct 1ms trigger.

 

STTwo-32
ST Employee

Try to adapt this example to your needs. It should work.

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 guess that you have problem with interrupt priority management.
I think some interrupt was occurred and it has higher priority than 1ms but it has less effect to 1s because it has long period.
do you use SystemTick in your system?
which it also has trig every 1ms too.
please check in  stm32xxx_it.c. there are trig inside that file. 

Why I am getting a Hardfault Handler error when using two timers together?

 

Again that 1ms is not working correctly but i tried for 100ms and 500ms it is working properly, but when i am using 2 timers together and when running the code i am getting an hardfault error handler. 

I suggest you to explain more details about your problem.
How is it not working?
How you implement those timer together?
and what is the last function before hardfault.
I guess that you should have more details to get help. 

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.

Thank You. 

Your timer calculations are correct and thanks for sharing the github code.