cancel
Showing results for 
Search instead for 
Did you mean: 

Standard Peripheral Library limits STM32F4xx USART to 7.5 Mbit/s, instead of max 10.5 Mbit/s

Diez.R.
Associate II

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

2 REPLIES 2
Diez.R.
Associate II

I just created an official support ticket for this issue, and I was immediately confronted with this answer:

"What is your company name and production forecast in thousands? Could you please provide more information about your application? This interface is for support of our customers. We have found for general questions like these your local ST authorized distributor FAE is available."

AvaTar
Lead

The SPL is officially deprecated, I wouldn't expect any (official) fix or enhancement from ST.

Investigating and fixing it yourself seems the best option.

Perhaps ST would do it, with enough sales in store ...

I didn't ever try to re-use the UART as SPI.

But as a frequent SPL user, I bypassed the SPL code whenever I saw fit (speed or missing functionality), and wrote to registers directly.