2025-04-23 11:39 AM
Hi everyone,
I'm using an STM32 timer in center-aligned mode, and I would like the counter to start from a value other than zero. Specifically, I want the timer to count from a custom value (e.g., 2000), up to the auto-reload value (ARR), and then count down again, repeatedly — like a normal center-aligned operation, but starting from a value other than 0.
Is there a way to set the initial value of the counter before the counting starts, so that the up/down counting occurs between a custom starting point and the ARR value?
I’m aware that I can use __HAL_TIM_SET_COUNTER() to set the counter to a custom value, but I’m not sure how it behaves in center-aligned mode or whether it interferes with the timing or alignment.
Any ideas or suggestions would be greatly appreciated!
Thanks in advance.
2025-04-23 12:10 PM - edited 2025-04-23 12:11 PM
Yes, set the counter value prior to starting the counter and it will start from there.
For example: