2021-10-05 07:45 AM
Hello everyone. Today I ran into an interesting and at the same time unpleasant problem. The same program is loaded into two identical microcontrollers, but the result of the work is completely different. The screenshot shows the data from the UART received from one and the other microcontroller.
Solved! Go to Solution.
2021-10-05 08:33 AM
Looks like the baud rate is slightly off, which causes the last bit (MSB) to be sampled during the stop bit, which makes it 1.
The internal HSI is not terribly accurate, although at 9600 baud it shouldn't be an issue. There have been cases reported where the factory-calibrated HSI was off by several percent. You can calibrate it or use HSE instead.
2021-10-05 08:33 AM
Looks like the baud rate is slightly off, which causes the last bit (MSB) to be sampled during the stop bit, which makes it 1.
The internal HSI is not terribly accurate, although at 9600 baud it shouldn't be an issue. There have been cases reported where the factory-calibrated HSI was off by several percent. You can calibrate it or use HSE instead.
2021-10-05 09:21 AM
Honestly it would be helpful to be specific about which STM32 model/family, and NUCLEO you're using, and the clock source you're running your code from.
MSI and HSI clocks frequently have calibration values that shouldn't be discarded.
2021-10-05 11:15 AM
Agree with previous comments:
UART/USART Asynchronous communication requires very accurate timing since there isn't a clock signal with the data .
Either:
- use a reliable clock when using any of these (UART, CAN, USB, etc.), or
- change to Synchronous Data Communications method (I2C, SPI, ...)
Paul