Skip to main content
PGare.1
Associate II
December 7, 2021
Solved

I am using stm32f103 for project and keil ide for the compilation. I have configured timer 2 having 16 MHz clk frequency. I need to generate interrupt at 100 ms so I have configured Prescaler val as 24 and period val as 63999. but getting at 95 or 11

  • December 7, 2021
  • 1 reply
  • 1806 views

..

This topic has been closed for replies.
Best answer by Peter BENSCH

The duration of the timer should be measured as directly as possible, e.g. by switching and measuring on a GPIO.

printf is not suitable for this use case, especially if its output is sent to Linux, which is not an RTOS with a predictable response time.

Regards

/Peter

1 reply

Peter BENSCH
Technical Moderator
December 7, 2021

Welcome, @PGare.1​, to the community!

do you use HSI as clock source?

Regards

/Peter

In order 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.
PGare.1
PGare.1Author
Associate II
December 7, 2021

Thanks for reply. No We are using HSE as clock source0693W00000HnmsgQAB.png

Peter BENSCH
Technical Moderator
December 7, 2021

OK.

Did you check the frequency coming from HSE using e.g. the pin MCO?

How did you measure the duration of TIM2?

Regards

/Peter

In order 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.