Closed IvanVnucec closed 2 years ago
I think I'was wrong, so let me explain why I think that:
To avoid a possible bug in HAL library, I have initialized UART by directly writing values into registers with the same configuration as stated in the comment above and the same problem appeared.
I was thinking that maybe the baud rate is different from the one configured. If you look closely at the first screenshot in the comment above, you could see that some sample points of the logic analyzer software are exactly on the signal edge, which is wrong. The sample point should be in the middle of the two signal edges, where the signal is most stable.
Then I was tinkering a bit with the baud rate in the logic analyzer decoder and with the 108000 bits/s I have managed to set sample points exactly in the middle of edges. See picture below: As you can see, UART is transmitting "bok\0" without any issues.
One of the main concerns why baud rate might differ from the one configured is that the UART clock source set to the HSI internal oscillator. 108000 bits/s differs by about 7% from the wanted 115200 bits/s.
Describe the set-up
Describe the bug When USART1 is configured as:
HAL_UART_Transmit(&huart1, pData, 4, 1000)
function transmits 4 packets, with each having 9 data bits instead of 8.How To Reproduce
STM32 Project
in STM32CubeIDEDescribe the bug
headingHAL_UART_Transmit
functionScreenshots Here is the screenshot of the Saleae Logic software with the "bok\0" data being sent. Clearly, the UART is sending 9 data bits instead of 8.
Furthermore, when I send "0xFF, 0xFF, 0xFF, 0xFF" then this happens: (in the above screenshot, I have set the Saleae Logic to decode UART with 9 data bits and the UART configuration is left unchanged)
HAL UART initialization code