0
\$\begingroup\$

What is the best way to transfer high-speed data (12.288 Mbit/s) from the STM32H723 microcontroller to a PC? I'm controlling a four-channel audio codec (AK4619vn) and need to sample the FFT of the signal received from the ADC on the PC. The STM32 MCU has an Ethernet port.

Do I need external memory to ensure continuous transmission without data loss, or is it possible to buffer the data within the MCU? Considering the received data speed is 12.288 Mbit/s.

PS: I'm using the SAI1 block to receive the data on two different blocks of the SAI1 (SAI1_A, SAI1_B), each handling 6.144 Mbit/s.

Thanks in advance!

\$\endgroup\$
2
  • \$\begingroup\$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. \$\endgroup\$
    – Community Bot
    Commented Jun 5 at 14:57
  • \$\begingroup\$ Sounds like you are making an USB sound card. Does the STM32 have USB? \$\endgroup\$
    – Justme
    Commented Jun 5 at 16:13

2 Answers 2

0
\$\begingroup\$

One possible way is use PSSI interface on STM32H7 and synchronous FT245 protocol on FT232H (which is USB 2.0 HS bridge). Both protocols are almost compatible. FT245 runs at 60MHz and PSSI can nominaly reach 50MHz, but i've succefuly tested that PSSI can operate at 60MHz. In that configuration you are able to transfer tens of MBs per second. May be it's not as straightforward as direct use of USB 2.0 High speed, but it is easy to setup and debug.

\$\endgroup\$
2
0
\$\begingroup\$

Easy solution: get a USB multichannel soundcard like Focusrite 4i4.

Otherwise, if you have the ethernet port on your board, then it depends if you have scatter gather DMA or not.

With bare metal scatter gather:

  • Prepare several buffers to hold UDP packets (header+data)

  • Use DMA to store data from SAI receivers into data portion of packet buffers

  • Once a buffer is full, the DMA raises an interrupt.

  • The CPU prepares UDP packet headers, checksum, etc, and triggers DMA to send it via ethernet. Note UDP checksum is not mandatory in IPv4 so if you don't add it, the CPU does not need to spend time reading the data at all.

Without scatter gather DMA, data will probably come into a ring buffer, so there's no space for UDP headers, it's all data. In this case, the CPU will need to copy all the data into UDP packets.

It would be a good idea to add some headers of your own, for example a packet sequence number, so you know if packets were dropped.

In both cases you need basic ethernet support services like ARP, also configure the ethernet peripheral obviously.

Performance and amount of implementation headaches will mostly depend on how the ethernet driver is implemented in the HAL. If it insists on copying all the data it may be too slow, or maybe not, depending on the mcu.

If the driver/mcu is fast enough you may be able to just use the UDP send packet function provided by the HAL, and you don't have to do the bare metal stuff outlined above.

I did it on a LPC4330 and the driver was very slow, I had to hit the hardware directly which took a while. I have no idea how it will work on STM32 but it should be doable.

With UDP obviously there is no retransmission in case a packet is dropped. This is okay on a LAN, if your cables are good, packets just aren't dropped at all. If you want that feature then you need to either use TCP/IP, which is not ideal for real time... or implement it via UDP.

Having a tiny amount of memory is only a problem if you expect transmission will be interrupted for long enough that you need to store all the data to send it later. If you use it on a LAN, you only need to keep a few 1kB packets in RAM at the same time since you can send the data in "fire and forget" as fast as it comes.

\$\endgroup\$

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