[SOLVED] Prescaler setting

Thread Starter

MTech1

Joined Feb 15, 2023
161
Hi,
I've observed that configuring prescaler settings in timers is a common settings. This involves dividing the input clock frequency of the timer. Just to add context, the 32-bit timer's input frequency is 32 MHz.

I'm interested to know how this division contributes to the measurement of longer time intervals, particularly in the context of any microcontrollers or ARM.

Could you please provide some explanations on this?
 

Thread Starter

MTech1

Joined Feb 15, 2023
161
What is your detailed explanation on this?
let me explain

Timer Purpose: In a microcontroller, a timer is a hardware component used to measure or generate time intervals. , it can be configured to measure a specific time interval.

Timer Size: I've chosen a 32-bit timer. This means the timer can count from 0 to a very large number (2^32 - 1), providing a wide range for measuring time intervals.

Clock Source: The timer relies on an external clock source to count time intervals. In this configuration, i uses a clock frequency of 32 MHz. This is the frequency at which the timer's counter increases by 1 with each clock cycle.

I want to know what happens when I set a pre-scaler of 1/4.?

Pre-scaler: set a pre-scaler of 1/4.
 

BobTPH

Joined Jun 5, 2013
8,661
I'm interested in understanding how dividing the clock frequency in a timer allows for longer time measurement
You have got to be kidding! If you have a counter that counts to 10, how long does that take with a clock pulse every second. How long with a clock pulse every 4 seconds?
 

Thread Starter

MTech1

Joined Feb 15, 2023
161
You have got to be kidding! If you have a counter that counts to 10, how long does that take with a clock pulse every second. How long with a clock pulse every 4 seconds?
Thank you. When we have a counter that counts to 10 and it's driven by a clock pulse every second, it will take 10 seconds to reach its maximum value.

However, if the same counter is driven by a clock pulse every 4 seconds, it will take 40 seconds to reach its maximum value because it only increments every 4 seconds.
 

tumbleweed

Joined Jun 27, 2023
15
Just in case it isn't obvious to you, when you use a prescaler it also reduces the timer resolution.
If you're counting 1MHz with a 1:1 prescaler you count in 1us increments.
If you use a 1:4 prescaler then the input clock gets divided by 4, so you now count in 4us increments.
 

BobTPH

Joined Jun 5, 2013
8,661
Thank you. When we have a counter that counts to 10 and it's driven by a clock pulse every second, it will take 10 seconds to reach its maximum value.

However, if the same counter is driven by a clock pulse every 4 seconds, it will take 40 seconds to reach its maximum value because it only increments every 4 seconds.
So, do you now understand why a pre-scaler allows for longer intervals?
 
Top