2024-01-26 01:22 AM
It is known the formula to calculate the update event is given by:
UpdateEvent = Timerclock / (Prescaler+1)(Period+1)
Considering that the TimerClock is 48MHz and I wish an Update Event of 0.5s. In theory, it can be achieved with different combinations of prescaler and period values.
My question is, how does the choice of the Prescaler and Period influence the system, is it better to have a higher Prescaler and a lower Period or vice-versa or it does not have a relevant impact at all?
Solved! Go to Solution.
2024-01-26 02:18 AM
Hello @GComes
First let me thank you for posting.
The choice of the prescaler and period values in the STM32 timer configuration can indeed have an impact on the system behavior. Let's understand how each parameter affects the timer operation:
1. Prescaler: The prescaler divides the timer clock frequency to generate the timer input frequency. It determines how fast the timer counts. A higher prescaler value will result in a slower counting rate, meaning the timer will take more time to reach the overflow or update event. Conversely, a lower prescaler value will make the timer count faster.
2. Period: The period determines the value at which the timer will overflow or generate an update event. It represents the maximum value the timer counter can reach before it overflows and restarts from zero. A higher period value corresponds to a longer counting time before the overflow or update event occurs. On the other hand, a lower period value will result in a shorter counting time.
If you choose a higher prescaler value and a lower period, the timer will count at a slower rate, resulting in a lower update event frequency. This can be advantageous if you want to reduce the interrupt load on the system or if you require less frequent updates.
Conversely, if you choose a lower prescaler value and a higher period, the timer will count at a faster rate, resulting in a higher update event frequency. This can be beneficial if you need more frequent updates or if you have time-critical operations that rely on precise timing.
Consider your system requirements, the desired update rate, and the processing capabilities of your STM32 microcontroller to determine the most suitable combination of prescaler and period values for your application.
Ghofrane
2024-01-26 02:15 AM
Hello @GComes,
A higher prescaler value will result in a slower clock frequency for the timer, which means the timer interrupt will occur less frequently but can result in less accurate timing...
however, a lower prescaler will result in a faster freq but increases power consumption for example
The Period value determines the duration of one cycle of the timer, so a higher Period value will result in a longer cycle and a lower frequency, and vice-versa
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-01-26 02:18 AM
Hello @GComes
First let me thank you for posting.
The choice of the prescaler and period values in the STM32 timer configuration can indeed have an impact on the system behavior. Let's understand how each parameter affects the timer operation:
1. Prescaler: The prescaler divides the timer clock frequency to generate the timer input frequency. It determines how fast the timer counts. A higher prescaler value will result in a slower counting rate, meaning the timer will take more time to reach the overflow or update event. Conversely, a lower prescaler value will make the timer count faster.
2. Period: The period determines the value at which the timer will overflow or generate an update event. It represents the maximum value the timer counter can reach before it overflows and restarts from zero. A higher period value corresponds to a longer counting time before the overflow or update event occurs. On the other hand, a lower period value will result in a shorter counting time.
If you choose a higher prescaler value and a lower period, the timer will count at a slower rate, resulting in a lower update event frequency. This can be advantageous if you want to reduce the interrupt load on the system or if you require less frequent updates.
Conversely, if you choose a lower prescaler value and a higher period, the timer will count at a faster rate, resulting in a higher update event frequency. This can be beneficial if you need more frequent updates or if you have time-critical operations that rely on precise timing.
Consider your system requirements, the desired update rate, and the processing capabilities of your STM32 microcontroller to determine the most suitable combination of prescaler and period values for your application.
Ghofrane
2024-01-26 02:43 AM
Thank you for the explanation; it was very clarifying.