Device configuration tool does not generate correct code for LPTIM Clock Mux
Hi,
uC: STM32G051K8U6, IDE: 1.14.1, MX: 6.10.0-RC9
I tried to generate some low frequency timeout using the LPTIM1 and the internal LSI time source, but it seems the code generator doesn't take in account the chosen option in the "LPTIM1 Clock Mux" selector. It seems it always choses the first option, whick is PCLK.
I confirmed this, generating the code with different options selected and comparing then using WinMerge. Nothing in the code changed.
After some searching, I found this function was responsible for initialising the clock source:
void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef* hlptim)
{
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
if(hlptim->Instance==LPTIM1)
{
/* USER CODE BEGIN LPTIM1_MspInit 0 */
/* USER CODE END LPTIM1_MspInit 0 */
/** Initializes the peripherals clocks
*/
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPTIM1;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{
Error_Handler();
}
/* Peripheral clock enable */
__HAL_RCC_LPTIM1_CLK_ENABLE();
/* LPTIM1 interrupt Init */
HAL_NVIC_SetPriority(TIM6_DAC_LPTIM1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM6_DAC_LPTIM1_IRQn);
/* USER CODE BEGIN LPTIM1_MspInit 1 */
/* USER CODE END LPTIM1_MspInit 1 */
}
}And I found out that adding the following line in the user code section solves the problem
/* USER CODE BEGIN LPTIM1_MspInit 0 */
PeriphClkInit.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_LSI;
/* USER CODE END LPTIM1_MspInit 0 */I did multiple tests, including enabling LMTIM1 and LPTIM2 and changing the clock sources in various ways, and it always generated the same output code. It seems there is a bug in the Device Configuration Tool.
If someone could confirm this is the right way to do it, I would appreciate it. Of course it would be nice to see this bug resolved in the upcoming version of the Code Generator. Anyone knows how to submit bugs of this kind?
Thanks,
Edwin
