2022-05-05 10:37 AM
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
The output from 2 terminal for usart1 and usart2.
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?
2022-05-05 12:12 PM
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
2022-05-05 01:44 PM
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?
2022-05-06 03:26 AM
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