1

I'm trying to understand every section of the journey of data from a microphone via a microcontroller to a pc terminal.

I realize now after reading about serial data transfer that real-time audio data transfer through a serial port is not possible, since the maximum data transfer rate is around 115 kb/s, However, I would still like to know about serial data transfer in a microcontroller.

I have an electret microphone connected to an analogue input on a stm32 nucleo-144 development board with a stm32F746ZG microcontroller (https://os.mbed.com/platforms/ST-Nucleo-F746ZG/) and the development board is connected to a pc via a USB cable.

My understanding is that the audio signal is sampled by the adc on the microcontroller chip, this new digital data is then moved to memory via one of the Advanced peripheral buses (APB) and then the Advanced High-performance bus (AHB) it then comes back out of memory and goes via the APB and AHB into a UART within the microcontroller and after into a (RS-232/RS-485) line driver (don't know if this is in the microcontroller on on the development board) where the voltage is increased and then after this I'm lost.

Does the data just progress along the tx line from the line driver to the USB port on the development board? And is it then transmitted as USB data or as serial data using one of the USB data lines?

A.Davies
  • 35
  • 1
  • 6
  • 1
    Nothing uses "one of the USB data lines"; the data lines are a differential pair and USB data always uses both. – Hearth Oct 28 '19 at 17:22
  • 3
    The situation you are describing sounds rather unlikely. Which STM32F4 development board has RS232? And why would you want to use it? Additionally, why do you want to send audio to a "terminal"? There are far better off-the-shelf ways to get audio into a PC. As for USB and various virtual serial schemes, these is something you can read up on - the purpose of Stack Exchange sites is not to replace documentation, but only to deal with questions which remain *after* consulting applicable documentation and references. – Chris Stratton Oct 28 '19 at 17:25
  • 1
    UART and USB are two separate things. – user110971 Oct 28 '19 at 17:25
  • I'm not entirely sure what you're asking. Are you asking what in the microcontroller is responsible for transmitting data to your PC? That answer can be found in the datasheet of the package of the SoC. Look for a block diagram towards the beginning of the datasheet. –  Oct 28 '19 at 17:29
  • I'm asking how does serial data actually get to the pc through a usb cable? is the serial data coverted to USB? – A.Davies Oct 28 '19 at 17:39
  • I thought stack exchange was for helping people, I've seen many questions on this site which could have been answered with consulting applicable documentation. I haven't found any documentation that has helped, which is why I asked on here. – A.Davies Oct 28 '19 at 17:46
  • I think the problem is that it isn't clear exactly what you are asking. How does serial data go through a USB cable? USB is already a serial bus. – evildemonic Oct 28 '19 at 17:47
  • A lot of dev boards fake a serial channel through the USB, is 5gat – Spehro Pefhany Oct 28 '19 at 17:49
  • 1
    STM32 doesn't use RS232 or RS485, then how does it send serial data? forgive my ignorance, I'm a beginner. Forget the audio situation I described, it's just an example to help my understanding, I just want to learn how data moves in the development board – A.Davies Oct 28 '19 at 17:49
  • I mean serial data using the RS-232 or RS-485 protocols – A.Davies Oct 28 '19 at 17:51
  • 2
    RS-232/485 are not protocols, they are line levels at those levels you would blow up the mcu. They define line levels and connector pin outs. not protocols. A very common mistake folks make trying to connect the dots between the protocol and the voltage levels/connector pinout. I have yet to see an STM32 dev board with RS-232 connectors or line levels, they use the debug mcu as a virtual com port instead. and that is a confusing/misleading term as well, com port. – old_timer Oct 28 '19 at 19:22
  • for the bigger nucleo boards the part that is perforated so that if you choose you can break it off. Thats basically an stlink debug board plus some other features. Not all, seems like half, but some also provide a virtual com port over usb. But it is at the 3.3V levels not RS-232C, between the debug board and the target mcu. You could also buy say an FTDI usb/serial chip (their chips usually are multi-function, say an FT2232 for example) breakout board use a host driver (linux sets it up by default this way) as a uart, then with jumpers wires to one of the other uarts on the target mcu. – old_timer Oct 28 '19 at 19:26
  • you can do the same thing a virtual usb uart/com port attached to one of the target mcu uarts, and the host through layers of operating system obfuscation will see that as a serial/uart port which you can use a dumb terminal program, minicom, teraterm, hyperterm, etc to interact with the mcu. granted you have to program the mcu. – old_timer Oct 28 '19 at 19:28
  • another missing piece here is that even though there is stlink support in that debug mcu there is yet another feature and that is it shows up as a virtual removable drive/media/thumb_drive and you simply copy your flash image .bin file over to this drive and the debug mcu uses SWD and reset control over the part to program the flash in the part for you, you dont need to come in through a debugger over stlink and run some number of commands. – old_timer Oct 28 '19 at 19:29
  • I have MANY STM32 nucleo boards all of them have the fake thumb drive thing and some version of stlink support. Only some provide a virtual serial/uart interface to the target mcu. The larger boards like this one you can pull the SWD jumpers and with jumper wires use the debugger to talk to other boards/chips, including non-ST cortex-ms. The smaller ones the debug and target are integrated into one board and you cant do this those signals are on the pcb and not to external pins. the copy the file thing pre-dated mbed but became part of how they do things. and it is a very nice feature. – old_timer Oct 28 '19 at 19:34
  • first thing you do when you get a nucleo board is get the firmware updater tool (java so runs on different operating systems) and update the debugger firmware, it doesnt always behave well on some systems, sometimes you can program the part one time and then have to unplug and replug the board. – old_timer Oct 28 '19 at 19:35
  • @old_timer, Thank you, my understanding is increasing with your input – A.Davies Oct 30 '19 at 16:17

1 Answers1

3

The serial interface is actually a virtual com port that communicates using the USB interface. Your microcontroller does not need to convert the serial input/output between normal logic levels and the higher RS-232 voltages...the logic signals from the UART go directly to the USB interface. Software on the host computer must be able to recognize the virtual serial port and provide the appropriate driver, so it looks just like an old fashioned serial port to the host software.

Elliot Alderson
  • 31,192
  • 5
  • 29
  • 67
  • 1
    Depending on which USB connector is used no actual UART may be involved at all. Using the one that goes through the on board debugger might be a default for experiments but would be less common when we creating a potential application product that used USB. – Chris Stratton Oct 28 '19 at 18:04
  • I understand now, thank you – A.Davies Oct 28 '19 at 18:21
  • You can create a virtual com port using the usb interface of the microcontroller? – A.Davies Oct 28 '19 at 18:22
  • Does this mean speed of the data transfer is not limited to 115 kb/s? – A.Davies Oct 28 '19 at 18:36
  • USB (more broadly than the CDC profile which exposes a virtual COM port) can support much higher data rates that 115kbps... like 480Mbps, but you have to write more software to get that kind of throughput. That being said even CDC can get 2Mbps if the MCU can support it, iirc. https://www.sony.com/electronics/support/articles/00024571 – vicatcu Oct 28 '19 at 18:42
  • 1
    @A.Davies You are asking new questions now, and the answers depend on whether you are asking about a specific microcontroller or about USB in general. You should probably create a new question and provide more details. – Elliot Alderson Oct 28 '19 at 18:44
  • Ok, I will do that – A.Davies Oct 28 '19 at 19:00
  • it is most definitely not RS-232. The nucleo boards like most ST dev boards have a debug interface (some other ST part) and the target mcu. the rx/tx (ttl levels) are connected between the debug and the target mcu on the board, sometimes through solder bridge jumpers. The debug board provides the virtual serial port on the usb side to its physical uart which is then connected to the target mcu so that what you see is the target mcu uart on the host. Look at the schematics. – old_timer Oct 28 '19 at 19:19
  • `signals from the UART go directly to the USB interface` I afraid it is wrong. Data received by UART is transferred to the USB peripheral via the special program. UART signals are not connected to USB. – 0___________ Oct 28 '19 at 22:15
  • @P__J__ - that depends on the connector used. The askers board has a direct USB connector they are probably *not* using, and it has a connector to a debugger chip that has the capability of collecting and proxying the signals of the _actual uart_ of the target chip. – Chris Stratton Oct 30 '19 at 18:21
  • Incidentally, a virtual com port has a "serial baud rate" only in the sense of a configuration hint to any UART generating an actual serial signal. If no actual UART is ever involved, the commanded baud rate is meaningless and ignored, data will flow as fast as it is provided and can be moved - you could command 300 baud yet actually accomplish a megabit. – Chris Stratton Oct 30 '19 at 18:31