Skip to main content
Associate II
October 13, 2025
Question

Bug: CubeMX code generation with LL HAL for timer

  • October 13, 2025
  • 2 replies
  • 376 views

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

 

rleighelectradx_0-1760362791939.png

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

2 replies

Technical Moderator
October 13, 2025

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.
Associate II
October 13, 2025

In case it matters, this was with an STM32U575ZIT part.

Technical Moderator
October 13, 2025

Hello @rleigh-electradx 

This issue has been raised to the development team for analysis and revision of upcoming releases (Ticket 207335 This is an internal tracking number and is not accessible or usable by customers).)

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.