• Glad you got this working with software serial.

    I just checked the code for serial on STM32 and we call through to the STM32 API and that would appear to be fine.

    However, checking on a scope, just calling Serial1.setup and printing something, I can see that as soon as you get below about 330, the baud rate goes completely wrong - I believe the baud rate register is overflowing and ST's API never does any kind of range checking.

    So you have two options:

    • Just use a baud rate of 330 - as you're having to use 316 on software serial, it's possible using 330 may work fine.
    • You can actually lower the clock rate of the UART so that then it can work without overflowing its counter. Run E.setClock({M:8, N:336, P:4, Q:7, PCLK1:2, PCLK2:8}) before you set up the UART and I believe that'll fix it!
About

Avatar for Gordon @Gordon started