Skip to main content
KChen.10
Associate
May 5, 2022
Question

using HSI16 on STM32L431KCU generate incorrect baud rate

  • May 5, 2022
  • 3 replies
  • 1671 views

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?

This topic has been closed for replies.

3 replies

waclawek.jan
Super User
May 5, 2022

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

KChen.10
KChen.10Author
Associate
May 5, 2022

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?

waclawek.jan
Super User
May 6, 2022

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