2018-02-11 04:59 AM
I found this by mistake.
I posted a problem waking up from Stop Mode 2 via LPUART
https://community.st.com/0D50X00009XkfHjSAJ
.The problem started when I used CubeMX generated code to use 80Mhz system clock instead of the HSI, while HSI stayed the LPUART clock.
The CubeMX generated the following line:
LL_RCC_HSI_SetCalibTrimming(16);
This is consistent with the datasheet that states:
Bits 30:24 HSITRIM[6:0]: HSI16 clock trimming (only HSITRIM[4:0] on STM32L475xx/476xx/486xx
devices)These bits provide an additional user-programmable trimming value that is added to theHSICAL[7:0] bits. It can be programmed to adjust to variations in voltage and temperaturethat influence the frequency of the HSI16.The default value is 16, which, when added to the HSICAL value, should trim the HSI16 to16 MHz ± 1 %.Once I masked this line the code functioned properly (when this line wasn't masked I got frame errors in the LPUART), and looking at HSITRIM I see the actual default value is 0x40.
#stm32l4 #trim #lpuart #hsi2018-02-13 09:50 AM
Hello
Ofri.Igal
,I checked that RCC_HSICALIBRATION_DEFAULT value is correct in the STM32CubeL4 with the default value 0x
I already raised this issue internally to correct
the reference manual with the number of bits containing HSITRIM[6:0] for the
default value set to 0xBest Regards
Imen
2018-02-14 02:02 AM
I started a new project using CubeMX Version 4.24.0
The project was for STM32L476QE, the default value is still 16.
2018-02-14 02:15 AM
Hello
Ofri.Igal
,You are right, I checked that
the default value is not correct
withCubeMX Version 4.0 and
I raised this internally to CubeMx team for fix.
Thank you for highlighting this issue, and Sorry for the inconvenience it may bring.
Best Regards,
Imen
2018-02-14 03:15 AM
The plot thickens :)
Looking at the STM32L476VG Discovery board, the default value of the trim field is 0x10 (as seen in IAR in reset state).
Both parts (STM32L496 & STM32L476) share the same datasheet.
STM32L496 (with Nucleo 144 board) is functioning perfectly with default trim value of 0x40 (though erroneously set to 0x10 by default in Cube), and the system wakes from LPUART with no problem.
Trying to set 0x40 to the trim value in STM32L476 resets the trim value as if it will not accept more than 5 bits in that field, unlike what the datasheet states.
The LPUART starts with frame error in that board (STM32L476VG Discovery) and I can't receive even 1 character. (I use PB10, PB11, PB12, PB13. The LCD screen is removed and I soldered a wire to R31, R32 positions after removing them)
2018-02-15 02:26 AM
DAHMEN.IMEN
I managed to get everything working, but there's an issue that needs to be resolved, probably in the reference guide (and checked in CubeMX, it might be OK there).
HSI default trim value is 0x10 for STM32L476 and 0x40 forSTM32L496 MCU.
HSI trim bit length is 5 forSTM32LSTM32L476 and 7 forSTM32L496
The datasheet doesn't clearly states that!
When the wake-up clock after Stop Mode is MSI and the LPUART is clocked from HSI it doesn't work unless you re-enable the HSI clock in the LPUART ISR. I will open a new discussion regarding this so it will be easier for other users to find.