cancel
Showing results for 
Search instead for 
Did you mean: 

using HSI16 on STM32L431KCU generate incorrect baud rate

KChen.10
Associate

I am trying to use HSI16 on STM32L431KCU but the usart is not generating the correct baud rate. I can only get the correct baud rate if using MSI.

I use CubeMX to generate my code from attached dmc300_l4.ioc.

Below is the clock tree for usart1 and usart2

0693W00000NpNZIQA3.png 

The output from 2 terminal for usart1 and usart2.

0693W00000NpNaQQAV.png 

We use other STM32L4 MCU, but it doesn't have this issue. Can you tell me why the STM32L431KCU HSI16 can not generate the correct baud rate?

3 REPLIES 3

Check RCC_ICSCR.HSITRIM. If it's not at its reset default (0x40), then it's Cube's wrecked code which overwrites it; this has been discussed here several times.

JW

Weird, the code set it to 0x40, but the baud rate is not working. If I set trim value to less than 0x2E, then I can get the correct baud rate. Does this mean I have to trim a different value for every single board?

That's weird, HSI should be calibrated out of factory, see datasheet.

Output HSI16 with a minimal program which does not change anything else in RCC directly to MCO and measure.

JW