cancel
Showing results for 
Search instead for 
Did you mean: 

PROBLEM WITH TIME IN STM32F2 SERIES

Arman Ilmak
Senior
Posted on February 21, 2018 at 18:25

Hey guys.

I'm working with an ultra sound piece for measuring the distance.

When i set the timer1 to count every 1 ms it works(i set PSC 59999 and ARR 1000 to get 1 second with 120M cpu clock.).

But when i set the PSC 11 and ARR 1 to get a 0.1 us interrupt its not correct and it doesn't count correctly. 

Do you know what is the problem?

15 REPLIES 15
Posted on February 22, 2018 at 12:58

ARR defaults to its max value. So if you don't do anything to it, the counter and roll to ffff and then 0.

Those mcus may have different constructs but the basic principles are the same, as long as you stay away from the libraries.

Posted on February 22, 2018 at 16:31

But when i set the ARR 0 the CNT does not count anymore!

Posted on February 22, 2018 at 16:37

No doubt, because the range of CNT is 0 to ARR inclusive

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on February 22, 2018 at 17:03

Yes but that requires arr to be explicitly set to 0. If you do so, there must be a valid reason.

Posted on February 22, 2018 at 21:43

] I use cube mx so in the TIM_init the ARR is set to 0.

Thanks guys for help.

Posted on February 22, 2018 at 22:11

That would seem to be a bug on the part of cube.