AnsweredAssumed Answered

Erroneous HSI default trim value in datasheet/CubeMX

Question asked by Clonimus74 on Feb 11, 2018
Latest reply on Feb 15, 2018 by Clonimus74

I found this by mistake.

I posted a problem waking up from Stop Mode 2 via LPUART here.

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:


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