2022-02-01 03:28 AM
I'm trying to setup a project with STM32CubeIDE 1.8 (includes CubeMX 6.4) that uses LPUART1 on a STM32L031K6. I want to lower the CPU frequency to 4MHz, and, to reduce power, I'm using HSI/4 as clock input.
LPUART baudrate is set wrong (4 times higher than expected according to logic analyzer), it's generated out of PCLK1 frequency that is assigned as HSI_VALUE >> 2. While HSI_VALUE is defined in stm32l0xx_ll_rcc.h:
#define HSI_VALUE (16000000U)
But, during debug I realize that HSI_VALUE value is 4000000, it is redefined as a compiler directive:
-mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DSTM32L031xx -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DMSI_VALUE=2097000 -DLSI_VALUE=37000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=0 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DHSI_VALUE=4000000 -c -I../Core/Inc -I../Drivers/STM32L0xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32L0xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage --specs=nano.specs -mfloat-abi=soft -mthumb
If HSI is not divided by 4 it's just redefined as 16000000 and everything works ok.
If I use HAL driver for RCC HSI_VALUE is not redefined as a compiler directive so it's ok too.
I know that I can delete that redefinition from project options, but it's added again if I change anything in CubeMX and generate code again.
Solved! Go to Solution.
2022-02-01 05:10 AM
Hello,
Thank you for sharing your issue,
I think HSI should not be redefined at compilation time, but this is my opinion.
I entered a ticket.
2022-02-01 05:10 AM
Hello,
Thank you for sharing your issue,
I think HSI should not be redefined at compilation time, but this is my opinion.
I entered a ticket.
2023-09-18 06:27 AM
Hello Mike,
This issue is still here with the most up-to-date version of the L0 package. Do you have any answer from the dev/support team ?
2023-09-18 06:41 AM - edited 2023-09-18 06:44 AM
@Brieuc When you create the project 1st time (generate code for CubeIDE), is the preprocessor symbol for HSE_VALUE defined in the project settings (not in any source or include file)? Is the value correct?
If you re-generate the project after changes in the clock/timing page, does the above mentioned preprocessor symbol change accordingly? If it does not - change it manually.
Note: Eclipse allows to override preprocessor symbols and options separately for every source file, be careful not to do this (unless you want exactly this).
2023-09-21 05:10 AM
Hi @Pavel A.
When I create a new project with HSE/4, there is no definition of HSI_VALUE in the project properties as long as I generate with the HAL drivers. After a switch to LL drivers in CubeMX and a generation, the .mxproject AND the project properties show DEFINES for all the clock sources, including HSI.