2018-10-16 04:47 AM
I'm trying to set Timer 2 (32 Bits) from Nucleo L432KC to measure input signals up to 1 kHz (for example). However, I'm confused about the selection of the prescaler and counter period.
I read in a book:
Another relevant condition is that the UEV frequency should be lower than the sampled signal frequency. The reason why this matters is evident: if the timer runs faster than the sampled signal, then it will overflow (that is, it runs out the Period counter) before it can sample the signal edges (see Figure 18). For this reason, it usually convenient to set the Period value to the maximum, and increase the Prescaler factor to lower the counting frequency.
My timer clock is running at 2 MHz. According to the advice of setting the period value to the maximum:
[Timer Frequency] / [(Prescaler+1)*(Period+1)]
[2MHz] / [(0+1)*(2^36)] = 2.91x10^-5 Hz?
Will I be safe using this configuration?
2018-10-16 06:09 AM
I would use the maximal period for the timer.
With a zero prescaler you'd get the most precision.
If you divide to 1mhz unit of ticks will be microseconds.
2018-10-16 06:13 AM
Hi @XP.1acheco ,
[Timer Frequency] / [(Prescaler+1)*(Period+1)] should be less than 1kHz (in your case)
-> If you shoose a Prescaler = 0 then the Period should be greater than (2*10^3 -1) .
In your case, Prescaler = 0 and (Period+1) = 2^32 (not 2^36) is a correct configuration.
Khouloud.