What are the consequences of disabling the "background" interrupt used by timer/ticker?

23 Mar 2019

I'm using the nucleo32f303k8.

I want to track an average period of an external interrupt in the audio range, but the uS timer doesn't allow for enough resolution.

So read the timer directly with the following:

 x=TIM2->CNT;

Timer2 is the only 32 bit timer. Unfortunately timer2 seems only count once per uS, which is also the timer used for the timer/ticker interrupt. If I set this timer to count with every clock cycle is the background interrupt going eat up all my processing time? If I don't use the ticker/timer/timeout APIs does this interrupt even get enabled? It's also used for the wait API as well, right?

I don't plan to use the ticker, wait or any time based APIs. I do want to use the I2C API, and I'm not sure where it get's it's clock frequency from.

I thought I'd run a quick test. I tried manually setting the prescaler, but the following seems to have no effect.

TIM2->PSC = 0x0000; 

Timer2 continues to count once per uS. I'm sure I'm missing something here.

03 Apr 2019

Hi Brian,

You have multiple possibilities:

_ You are not using multitasking then disable the SYSCLOCK (timer/ticker) with no impact.

_ You need multitasking switch the SYSCLOCK to a different timer.

I assume that you are measuring the Audio frequency of a signal to do this you need to slow down the timer not increase-it .To slow down the timer you need to increase the PSC you also need to fine tune the resolution by adjusting the ARR(auto reload register).

Here is the relation between Time(period) and Frequency and vice versa T=1/f, f=1/T.

I suggest that you download "RM0316 Reference manual" from st.com and read the sections on timers. Also download the firmware for your processor they contains example on how to measure time and frequency without using interrupt.

Good Luck