cancel
Showing results for 
Search instead for 
Did you mean: 

Erroneous HSI default trim value in datasheet/CubeMX

Clonimus74
Senior II
Posted on February 11, 2018 at 13:59

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 the

HSICAL[7:0] bits. It can be programmed to adjust to variations in voltage and temperature

that influence the frequency of the HSI16.

The default value is 16, which, when added to the HSICAL value, should trim the HSI16 to

16 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.

0690X00000609UfQAI.png

#stm32l4 #trim #lpuart #hsi
5 REPLIES 5
Imen.D
ST Employee
Posted on February 13, 2018 at 18:50

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 0x

Best Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on February 14, 2018 at 10:02

I started a new project using CubeMX Version 4.24.0

The project was for STM32L476QE, the default value is still 16.

0690X00000609jYQAQ.png
Posted on February 14, 2018 at 10:15

Hello

Ofri.Igal

,

You are right, I checked that

the default value is not correct

with

CubeMX 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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on February 14, 2018 at 11:15

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)

Posted on February 15, 2018 at 10:26

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.