Skip to main content
MSzal.1
Associate II
November 3, 2021
Solved

I have an STM32F411RE nucleoboard. I tried to test my delay fnc with input cpature mode. It seems the prescaler not divide the frequency only after overflow of the capture compare register.

  • November 3, 2021
  • 1 reply
  • 1686 views

Hi everybody!

First of all sorry for my language. I just started to learning programming of STM32. My problem is that i made a delay function. I wanted to test it with the input capture mode. I setted the prescaler to 16000 - 1. I wanted to get an 1000 Hz sampling. When I start to debug the project as you can see in the microsecs_wrong.png file, the difference between the timestamps is 32.000.000. The interesting part is when the capture compare register reaches 4294967295 (2^32 - 1) it overflows and start to works properly (microsecs_proper_working.png). The difference between timestamps now is 2000. Why is that happening?

Thanks for Your help!! :)

This topic has been closed for replies.
Best answer by TDK

The PSC and ARR registers are preloaded by default. If you want them to take effect immediately, generate an update event after setting it but before enabling the timer.

TIM2->EGR = TIM_EGR_UG;

1 reply

TDK
TDKBest answer
November 3, 2021

The PSC and ARR registers are preloaded by default. If you want them to take effect immediately, generate an update event after setting it but before enabling the timer.

TIM2->EGR = TIM_EGR_UG;

"If you feel a post has answered your question, please click ""Accept as Solution""."
MSzal.1
MSzal.1Author
Associate II
November 3, 2021

It works fine! Thank you!! :)