0
\$\begingroup\$

I'm trying to transmit data at 6.144 Mbit/s through the UART port of Nucleo-H723ZG microcontroller. For reading on the PC, I'm using Free Device Monitoring Studio. Based on my UART parameters, I should be receiving data at 6.144 MBit/s, but what I'm actually receiving on the PC is only 2.4 Mbit/s.

Here is a screenshot of an 11 second recording that I made:

11 second of registration

Here the STMCubeIDE parameters:

enter image description here

And here are the parameters I configured in the software tool:

enter image description here

I'm not performing any memory management in the MCU. The only code is for receiving the data from SAI (Serial Audio Interface) and transmitting it to the UART port, as shown in the image:

enter image description here

I'm wondering if the issue is due to a software error in the microcontroller or if there are limitations in the serial reading on the PC. Any insights would be greatly appreciated.

\$\endgroup\$
9
  • 1
    \$\begingroup\$ Do you have a scope or a logic analyzer, to measure the bit timing? Bottlenecks can exist in every layer of your stack - PC, Hardware or embedded SW. \$\endgroup\$
    – Lior Bilia
    Commented Jun 20 at 15:18
  • 2
    \$\begingroup\$ PPP seems really wrong. It's for encapsulating ethernet over the top of a serial port, not for generic serial communications. \$\endgroup\$
    – Ben Voigt
    Commented Jun 20 at 15:53
  • 1
    \$\begingroup\$ Your functions appear to be blocking and not interrupt / DMA driven. That means you will receive 16 bytes on the audio port (and do nothing else in that time) and then transmit 16 bytes on the UART (and do nothing else in that time). You can see the code for the HAL_UART_TRANSMIT in this question. stackoverflow.com/questions/72041049/… First answer, scroll down to 'blocking' \$\endgroup\$ Commented Jun 20 at 16:00
  • 1
    \$\begingroup\$ I was running out of characters. The way I would handle this is using DMA and ping pong buffers. See audiodsplab.wordpress.com/ping-pong-buffer-audio-stream \$\endgroup\$ Commented Jun 20 at 16:03
  • 1
    \$\begingroup\$ What are you using as UART on the PC and can it do 6875000 bps? It may be very rare rate. I use 12 Mbps between MCU and PC USB UART chipset and it works fine. Your PC UART may be incapable of either the specific baud rate or that rate of actual data sent. \$\endgroup\$
    – Justme
    Commented Jun 20 at 17:49

1 Answer 1

0
\$\begingroup\$

Your desired communication speed have to meet equation from 53.5.7 USART baud rate generation in Reference manual.

Baudrate = USART_kernel_clock / USARTDIV

where USARTDIV is integer and must be higher then 16. If you select oversampling to 8 samples, then equation becomes to

Baudrate = 2*USART_kernel_clock / USARTDIV

Which is more suitable for high communication speeds. Space of available baudrates is spares in range of high buadrates. Imagine that your USART_kernel_clock is 120MHz. Then with oversamplig 8, you can select USARTDIV to 39 and speed will be 6.154Mb/s which is close enought to be tolerated. If you select USARTDIV to 40 your baudrate will be 6Mb/s. Nothing between theese two numbers !

If you need to be more flexible with choosing baudrates you can also clock USART directly from PLL.

\$\endgroup\$
2
  • \$\begingroup\$ The register value calculation is not that straightforward. In 16x mode it might be but in 8x mode you have only 3 selector bits for the fractional baud rate generator and bit 3 must be zero so divisor of 40 is invalid. Also to transmit 6.144 Mbps worth of payload data you need the UART to have at least 7.68 Mbps due to start&stop bits, preferably higher. Depending on the PC side, it might not be select any arbitrary baud rate but 8, 10 or 12 Mbps could be possible common rates on both the STM32 and PC. \$\endgroup\$
    – Justme
    Commented Jun 23 at 7:32
  • \$\begingroup\$ You are right, baudrates selection is also limited by 3rd bit of USARTDIV. It is not clear what type of device is recieveing that data. If it is ordinary USB-UART Bridge (FTDI etc.) then baudrate selection is limited like you write and moreover there will be need for hardware flow control and bridge have to be equiped with USB 2.0 High speed. \$\endgroup\$ Commented Jun 23 at 8:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.