0
\$\begingroup\$

I'm currently facing a big problem. I've an MCU (STM32L4) connected to an SD card (SDIO) which stores tons of data (5Gb) from a microphone. I need to send this data as fast as possible from SD card to my PC. With a serial port this is to slow, since the max baud rate of my MCU is 115kb/s. How can I solve this? I'm thinking about using an FTDI module but for what I'm reading the speed is always limited by MCU baud rate. Best Regards

\$\endgroup\$
  • \$\begingroup\$ Why not remove the SD card and connect to PC? Does the STM32L4 you use have USB? MCU may not the limit, FTDI modules can be, depending on which you use - Which FTDI module do you mean? Why is the MCU limited to 115200, why can't you change it? \$\endgroup\$ – Justme Aug 4 at 18:38
  • \$\begingroup\$ You can't unplug the SD card and insert it into the computer? Is your 32L4 one of the ones with USB or USB OTG? \$\endgroup\$ – Ron Beyer Aug 4 at 18:39
  • \$\begingroup\$ 32L4 family has MCUs with USB support. Maybe you should pick one of those so that you are not limited to the baudrate of FTDI/UART. \$\endgroup\$ – Rohat Kılıç Aug 4 at 18:42
  • \$\begingroup\$ Miguel, it appears you are using the really-simple-to-use (but not so fast) virtual COM port HID support driver that is ubiquitous on PCs over USB connections. That's not ever going to be fast and it is probably mediated by a separate chip on your MCU board that you have NO CONTROL over. You'll need a direct USB connection and you'll need to write (or find) software drivers for BOTH SIDES of the wire to get high speed over USB. You are entering difficult territory now. For example: PIC18F4XJ5X Full-Speed USB Demonstration Board. \$\endgroup\$ – jonk Aug 4 at 18:43
  • \$\begingroup\$ @jonk thank you. My MCU already has USB peripheral but its max speed is 12Mbit/s. So are you sugesting me to change the MCU? \$\endgroup\$ – Miguel Andrade Aug 4 at 19:03
1
\$\begingroup\$

If you clock the STM32 with a 64MHz clock and use the over-sample by 8 mode then you can get up to 8Mbps data rates just using the UART.

The FTDI cables support data rates much faster than 115200 bps. In some cases you may have to use the D2XX drivers instead of the COM port drivers.

TTL-232RG-VREG3V3-WE
3.3V TTL UART, up to 3Mbps baud rate.
https://www.ftdichip.com/Products/Cables/USBTTLSerial.htm

NOTE: Due to 128 byte RX buffer and 1kHz USB full-speed frame timing. Sustained transfer rate is limited to 1kHz * 128 bytes * 8 bits/Byte = 1.024,Mbps.

C232HD-DDHSP-0
3.3V TTL UART, up to 12Mbps baud rate.
https://www.ftdichip.com/Products/Cables/USBMPSSE.htm

NOTE: Due to 1K byte RX buffer and 8kHz USB hi-speed frame timing. Sustained transfer rate is limited to 8kHz * 1K bytes * 8 bits/Byte = 8.192 Mbps.

C232HM-DDHSL-0
3.3V TTL UART, up to 30Mbps
https://www.ftdichip.com/Products/Cables/USBMPSSE.htm

NOTE: Due to 1K byte RX buffer and 8kHz USB hi-speed frame timing. Sustained transfer rate is limited to 8kHz * 1K bytes * 8 bits/Byte = 8.192 Mbps.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ But FTDI module amplifies that 115200bps rate? \$\endgroup\$ – Miguel Andrade Aug 4 at 21:58
  • \$\begingroup\$ I am not sure what you mean by "amplifies". The FTDI module and the MCU need to be set at the same baud rate. Obviously it can't take or put data faster than the interface on the MCU side. But on the STM32 the hardware limit seems to be 8Mbps, unless you are using a transceiver or a clock source that imposes a lower limit. \$\endgroup\$ – user4574 Aug 4 at 22:18
  • \$\begingroup\$ Please note that FTDI has a FIFO that may limit the transfer rate. Even if the FT232RL cable can use 3 Mbps baud rate, it has a 256 and 128 byte RX and TX FIFOs. As USB scheduling with 12Mbps USB peripherals works at about 1ms or 1000Hz rate, it means continuous data flow at 3Mbps is impossible and depending on direction only up to 2.56 Mbps and 1.28 Mbps is achievable. \$\endgroup\$ – Justme Aug 4 at 22:56
  • \$\begingroup\$ Why assuming only "full speed" instead of "high speed" USB? I justed measured with a FT2232H mini module the continous rate and the result is ~1.200000 words per second (if 12000000 baud rate is set). A word is 8 data bits + 1 start bit + 1 stop bit. So the 12 Mbps are exactly reached and sustained over long periods. The FT232H is afaik basicially the same only with one port and the C232HM and C232HD are both based on the FT232H. TL;DR if the USB is not artifically slowed down the FTs deliver the promised data rate to the best of my knowledge and test. Or did I miss anything? \$\endgroup\$ – Christian B. Aug 6 at 21:16
  • \$\begingroup\$ @ChristianB. That's good to know about the FT232H. I did assume USB Hi-Speed. Thats why you see an 8KHz micro-frame timing in the calculation. But I still only got about 1.024 million bytes per second in the calculation. It would be interesting to know what they are doing in the driver to get the full data rate. FYI, I have also run tests on some of their RS485 cables that advertised 3Mbps, and I got the full 3Mbps sustained rate out of them also. \$\endgroup\$ – user4574 Aug 7 at 4:47
1
\$\begingroup\$

If you really want to do this "as fast as possible" you should either move the card to a reader in a PC, or embed a USB SD reader and a USB mux. Your MCU can access the card through the mux and reader, and then when unnecessary unmount the filesystem, flip the mux switch, and expose the card as USB mass storage at the full hardware speed. This isn't an original idea - some smartphone card readers do exactly this only using a Linux WiFi SoC (instead of MCU) to provide one access mode while USB provides the other.

Or you could implement USB mass storage in your MCU, but that's going to be slower, not just because you'll be at a lower USB bandwidth but because you may not have sufficient buffer memory to sustain what the bus could move.

Consider what read speed the card can support in a reader on a PC, you won't get faster than that, so pick an approach that isn't too much worse.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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