Error in default HSI calibration value in LL generated code for NCULEO L452RE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-08 10:21 PM
This topic was covered for the case of HAL in this thread:
But my case is for LL which still seems to have this issue, in the generated code.
I found this problem because the baud rate of 115200 on USART2 was so far off that serial comms was not possible. This is only a problem when RCC is set to use LL. When RCC is set to use HAL, the correct value of 64 is used for HSI calibration and I had no serial comms problem.
I believe I am on latest STM32CubeIDE software and toolchain repository for my board:
STM32CubeIDE:
Version: 1.6.1
Build: 9958_20210326_1446 (UTC)
Repository version: STM32Cube_FW_L4_V1.17.0
Another issue: It seems the Configuration Pane for RCC will not let me set this parameter (HSI Calibration Value) to the correct default value of 64. It is being limited to 31.
The generated code from main.c is below. The line in question is:
LL_RCC_HSI_SetCalibTrimming(16);
-----------------------------
void SystemClock_Config(void)
{
LL_FLASH_SetLatency(LL_FLASH_LATENCY_4);
while(LL_FLASH_GetLatency()!= LL_FLASH_LATENCY_4)
{
}
LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1);
LL_RCC_HSI_Enable();
/* Wait till HSI is ready */
while(LL_RCC_HSI_IsReady() != 1)
{
}
LL_RCC_HSI_SetCalibTrimming(16);
LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_1, 10, LL_RCC_PLLR_DIV_2);
LL_RCC_PLL_EnableDomain_SYS();
LL_RCC_PLL_Enable();
/* Wait till PLL is ready */
while(LL_RCC_PLL_IsReady() != 1)
{
}
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL);
/* Wait till System clock is ready */
while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL)
{
}
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1);
LL_Init1msTick(80000000);
LL_SetSystemCoreClock(80000000);
LL_RCC_SetUSARTClockSource(LL_RCC_USART2_CLKSOURCE_PCLK1);
LL_RCC_SetUSARTClockSource(LL_RCC_USART3_CLKSOURCE_PCLK1);
}
- Labels:
-
Bug-report
-
RCC
-
STM32CubeMX
-
STM32L4 series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-08 10:24 PM
I forgot to add: when setting RCC to use LL, if I edited the generated code to use 64 (rather than 16) for HSI calibration, this also fixed the problem. So it is very clear that is what the problem is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-09 4:59 AM
Hello @GSchr.3​ and welcome to the Community :)
Thanks for your reported issue.
I rasied this to CubeMX team for check and analysis.
Thanks
Imen
Thanks
Imen
