Electrical – data transfer limit for virtual serial ports

audiomicrocontrollerserialsignal processingstm32

I want to record 5/10 seconds of audio using an electret microphone and an STM32 nucleo development board and send it to my computer in real-time to be processed. I'm a beginner so I'm sure I'm making mistakes, but what limits the data transfer speed for a virtual serial port? I want to sample the audio at 48 kHz, at 12-bits per sample, which by calculation means I need a data transfer rate of 576 kb/s, is that possible via the virtual serial port? if not, is it possible at all with this board?

I have the STM32 nucleo-144 development board, I'm using mbed (https://os.mbed.com/platforms/ST-Nucleo-F746ZG/) and a electret microphone circuit (https://docs-emea.rs-online.com/webdocs/00af/0900766b800affa3.pdf)

Best Answer

This is explicitly a "X-Y problem". You have a typical audio application. To implement the real-time data processing for the signal, you have two basic options:

  1. Implement the most trivial and common and easy USB class - CDC (aka "virtual COM port"). To accomplish the overall data processing goal, you will need to invent a method/format to pack the electret mic ADC data into UART-type stream, then use a common Windows/Linux COM-port driver to buffer and store the data, and then to develop a proprietary application do deal with your proprietary format. The plus of this approach is that you control the raw data format and don't need to dig any specifications for the data stream. Minuses of this approach is that you will need to develop a lot of your own code.

  2. Since this is an audio device, the formal solution is to implement the audio-class USB device within the Nucleo board. As I understand, there are code examples form STM development, see USB Audio device class on NUCLEO-F446RE and USB Audio device on Nucleo F446-RE with CubeMX. Advantages of this approach would be all well-established libraries in all known operating systems. Minus side is that you need to dig into audio specifications.

In all cases the bandwidth of USB (even in FS mode) is well sufficient for audio processing tasks.