2025-10-13 6:45 AM
Hi,
CubeMX version 6.15.0 with STM32U5 HAL 1.8.0.
<project>/XP2/Core/Src/tim.c: In function 'MX_TIM5_Init':
<project>/XP2/Core/Src/tim.c:228:30: error: conversion from 'long unsigned int' to 'uint16_t' {aka 'short unsigned int'} changes value from '4294967196' to '65436' [-Werror=overflow]
228 | TIM_InitStruct.Prescaler = 156-LL_TIM_ETR_FILTER_FDIV1_N2;
| ^~~
cc1.exe: all warnings being treated as errors
The prescaler setting of "156-1" should be 155 when set, but the code is actually this:
/* USER CODE END TIM5_Init 1 */
TIM_InitStruct.Prescaler = 156-LL_TIM_ETR_FILTER_FDIV1_N2;
TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
TIM_InitStruct.Autoreload = 4294967295;
TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1;
LL_TIM_Init(TIM5, &TIM_InitStruct);
LL_TIM_DisableARRPreload(TIM5);
LL_TIM_SetClockSource(TIM5, LL_TIM_CLOCKSOURCE_INTERNAL);
LL_TIM_SetTriggerOutput(TIM5, LL_TIM_TRGO_RESET);
LL_TIM_DisableMasterSlaveMode(TIM5);
/* USER CODE BEGIN TIM5_Init 2 */
Where did the LL_TIM_ETR_FILTER_FDIV1_N2 come from? This has replaced the calculation I entered in the prescaler configuration, above.
Kind regards,
Roger
2025-10-13 7:10 AM
Hello @rleigh-electradx
Thank you for your contribution!
I am currently checking this issue, and I will get back to you ASAP.
KR, Souhaib
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.
2025-10-13 7:12 AM
In case it matters, this was with an STM32U575ZIT part.