cancel
Showing results for 
Search instead for 
Did you mean: 

Correct use of UIF for counting internal clock pulses

Onkar Chincholkar
Associate II
Posted on January 19, 2018 at 11:49

I am working on STM32 discovery board to develop a counter functionality of the timer1 using internal clock cycles.

The update interrupt flag goes high every time the (CNT ==0) also as soon as I enable the counter the it starts from 0(overriding any previous value written on CNT) setting the update interrupt flag high as soon as the counter has started. What is the use of UIF then?

My observations -

As I step over the line

TIMx->CR1 |= TIM_CR1_CEN; and observe the registers

the UIF flag in the SR register goes high and CNT register shows 0x39(for prescalar 0xfff0).

When pre scalar is changed to 0x3fff the stepping over sets the UIF flag and CNT is holding 0xee.

One can correlate the timings that when pre scalar is halved counter value almost doubles. If there is some mistake in my understanding please correct.

Controller used - STM32F051R8T6(Discovery board)

IDE used - Attolic truestudio

Thanks and regards

Onkar

#stm32f0-counter
0 REPLIES 0