summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'stmhal/timer.c')
-rw-r--r--stmhal/timer.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/stmhal/timer.c b/stmhal/timer.c
index 14ef3cc4a9..5efecbc9d2 100644
--- a/stmhal/timer.c
+++ b/stmhal/timer.c
@@ -181,7 +181,7 @@ void timer_tim3_init(void) {
TIM3_Handle.Instance = TIM3;
TIM3_Handle.Init.Period = (USBD_CDC_POLLING_INTERVAL*1000) - 1; // TIM3 fires every USBD_CDC_POLLING_INTERVAL ms
- TIM3_Handle.Init.Prescaler = 84-1; // for System clock at 168MHz, TIM3 runs at 1MHz
+ TIM3_Handle.Init.Prescaler = 2 * HAL_RCC_GetPCLK1Freq() / 1000000 - 1; // TIM3 runs at 1MHz
TIM3_Handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
TIM3_Handle.Init.CounterMode = TIM_COUNTERMODE_UP;
HAL_TIM_Base_Init(&TIM3_Handle);