2022-03-05 09:55 PM
Hello, I want to generate an interrupt using the timer update event every T seconds at a given MCU frequency F using LL library and a basic timer with STM32L071CB.
Lets say for example that:
T = 5 s
System clock frequency F = 32 MHz
Timer TIM6
It looks like a simple task but it's difficult for me to understand the math behind these operations.
Solved! Go to Solution.
2022-03-06 01:08 AM
Basic timer features include:
Time to int = TIMperipheral CLK (APB) / (PRESC + 1) / (ARR + 1)
calculate for ARR=999 for example 1 sec and changing ARR 1999 is 2 sec ...For your T and F PRSC=31999 ARR=4999
Or more info
The update event period is calculated as follows:
Update_event = TIM_CLK/((PSC + 1)*(ARR + 1)*(RCR + 1))
Where: TIM_CLK = timer clock input
PSC = 16-bit prescaler register
ARR = 16/32-bit Autoreload register
RCR = 16-bit repetition counter (where present)
URL:
http://www.st.com/web/en/resource/technical/document/application_note/DM00042534.pdf
2022-03-06 01:08 AM
Basic timer features include:
Time to int = TIMperipheral CLK (APB) / (PRESC + 1) / (ARR + 1)
calculate for ARR=999 for example 1 sec and changing ARR 1999 is 2 sec ...For your T and F PRSC=31999 ARR=4999
Or more info
The update event period is calculated as follows:
Update_event = TIM_CLK/((PSC + 1)*(ARR + 1)*(RCR + 1))
Where: TIM_CLK = timer clock input
PSC = 16-bit prescaler register
ARR = 16/32-bit Autoreload register
RCR = 16-bit repetition counter (where present)
URL:
http://www.st.com/web/en/resource/technical/document/application_note/DM00042534.pdf
2022-03-06 02:17 AM
Thank you MM
Regards
2022-03-06 02:56 AM
2022-03-07 03:35 AM
Thank you Nikita91