Standard Peripheral Library limits STM32F4xx USART to 7.5 Mbit/s, instead of max 10.5 Mbit/s
I am using the STM32 Standard Peripheral Library for STM32F4xx, part number STSW-STM32065 , version 1.8.0.
I am using USART6 on a STM32F407 to do SPI transfers. Unfortunately, I ran out of real SPI interfaces. But USART6 has an "SPI master mode" which can do SPI too.
The microcontroller is running at its maximum of 168 MHz.
According to the datasheet, USART6 can go up to 10.5 Mbit/s. USART transfers have a start bit and and stop bit, even in SPI mode, so the real data transfer will probably be less than that (10 clock cycles for every 8 bits transferred).
In any case, file stm32f4xx_usart.h has the following definition:
#define IS_USART_BAUDRATE(BAUDRATE) (((BAUDRATE) > 0) && ((BAUDRATE) < 7500001))
That limits the baud rate to 7.5 Mbit/s. Any higher speed triggers then an assert in the library.
Is that a bug?
I tried to disable the assert, but something is probably not quite right with the internal calculations, because I could not achieve the maximum 10.5 Mbit/s baud rate. I would have to research more. Does the maximum baud rate depend on the CPU frequency? Maybe you cannot achieve exactly 10.5 Mbits if you are running at exactly 168 MHz.
Can anybody help?
Many thanks,
R. Diez
