Divide and conquer, or write slowly - read quickly


In one of my projects, it became necessary to sequentially record digitized data sets from 3 ADC channels. The measurement results had to be saved at a speed of 6 KBytes / s, while the duration of the data collection cycle could be a day or more. Thus, the total amount of information that needed to be stored was 500 MB or more. As a storage device, it was decided to choose an SD card.


The task was complicated by the fact that the design features of the device being created did not allow the card to be retrieved for reading data. The XMega128A4U controller , on which the task was being implemented at that time, did not have hardware support for SDIO, but allowed working with the card via the SPI interface, the bandwidth of which was fully capable of writing at the required speed, but reading this amount of data into the computer via the SD card -> controller -> USB-Com converter was rather dreary and took a lot of time.


After some deliberation (and unsuccessful attempts to somewhat disperse the above combination), it was decided to use a hardware SD Card Reader Controller, which was the GL823 chip that supports USB 2.0. Now it was necessary to provide separate access to the SD card from the controller side via SPI during data acquisition and from the computer side via SDIO, using the GL823 during high-speed reading. This separation was implemented using two 4x 2x1 multiplexers.



The lines from the U2, U3 switches with the “STM” prefix are connected to the controller, the lines with the “SD” prefix to the SD card. To control the circuit, the SD2MCU signals are used, switching the SD card between the MCU and GL823 and GL823_PWR, switching through the mosfet power supply GL823 .


Initially, I considered such an approach as a kind of “crutch”, but, to my great surprise, it turned out to be quite efficient and was confirmed by the practice of successful operation of the device for several years.


Moreover, in the following developments based on the STM32F407 , which has both SDIO support for accessing the card and the possibility of raising the USB 2.0 HS MSD (albeit via a parallel ULPI interface), the possibility of using a bus- based GL823 solution is being considered .


Using a bunch of STM32F407 with an external PHY USB3300, it was possible to achieve a card reading speed of ~ 41 Mbps, while using a hardware card reader, the speed reaches ~ 150 Mbps with other conditions being equal. The measurements were made by reading a 128 MB file from an SD card formatted in FAT32. Both approaches have their own nuances of use, but, as it seems to me, both have a “right to life”. As for the nuances: in my case, during the next iteration of the development of this device, the hardware had to be placed on a 26 mm wide board.


The PCB layout for the LQFP100 of the STM32F407 package is somewhat difficult in this case, but its “younger brother” STM32F405 in the LQFP64 package was even placed. But, the STM32F405 has no ULPI, hence USB 2.0 HS is not available for it, and the MSD FS implementation loses much of the speed of reading data from the card. Using the same solution described above, you can get sufficient speed of access to the SD from the computer while reading data from the device.


I would be glad if my experience will be useful for someone.



Also popular now: