When I set uart baudrate, it will prompt :
>>> uart=UART(2)
>>> uart.init(9600)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: set baudrate 2459173 is not within 5% of desired value
But baudrate is set correctly and uart works.
UART baudrate error in STM32L476
Re: UART baudrate error in STM32L476
Looks like line 583 in stmhal/uart.c is the culprit. It has a special treatment for the L4 series, which seems not needed here.
I do not have the board, so I cannot check it.
Best Regards, Robert
I do not have the board, so I cannot check it.
Code: Select all
#if defined(MCU_SERIES_L4)
actual_baudrate = (actual_baudrate << 5) / (self->uart.Instance->BRR >> 3);
#else
actual_baudrate /= self->uart.Instance->BRR;
#endif
Re: UART baudrate error in STM32L476
The baud rate calculation between L4 and F4 is different, See Reference Manual F4:Sec 30.3.4, P 971 (Rev 11, Oct 15) and L4 Sec 36.5.4 Page 1184 (Rev 1, May 15). During the port I by mistake took the definition for LPUART which is again different (L4 sec 37.4.4).
I will fix the calculation and do a PR.
I will fix the calculation and do a PR.
badi