0
\$\begingroup\$

i need to be able to update this memory storage device 1000 times per second via MCU in small 8 byte of data chunks trasnfers, and then read back the data into the PC. Should I go for the USB SD card reader - easily r/w from both MCU dev board and PC, or is it too slow for such small and fast transfers ? in the latter case - any cheaper-than-flash-programmer way to read it back into PC ?

edit

The data comes from sensors -> MCU algorithm, 8 bytes each milisecond. I need to store no more than 5 minutes of such data ~ 2.4 MB, but having 1-2 hours of it might prove useful later. I shall then transfer it on a PC in order to plot it on a graph or otherwise analyze it.

\$\endgroup\$
1
\$\begingroup\$

i need to be able to update this memory storage device 1000 times per second via MCU in small 8 byte of data chunks trasnfers,

then Flash is the wrong kind of memory for you. Look up how Flash needs to be written. (hint: block erases make your 8 B transfers extremely undesirable)

Also, when you do that for a long time, I hope you make sure your firmware does wear leveling – SPI flash itself (usually) doesn't (SD cards have a built-in MCU that hides the raw memory from you and does error correction and wear leveling for you).

Should I go for the USB SD card reader - easily r/w from both MCU dev board and PC, or is it too slow for such small and fast transfers ?

The 1000 writes of 8 Bytes is 64 kbit/s. Your transfer rate isn't even remotely fast. It's just badly structured.

To solve the structure issue, you need aggregate data that needs to be written in your MCU RAM and write it in larger consecutive chunks (maybe you need to change your data structures to allow for that, I don't know what you're doing).

You need serious amounts of RAM, anyway, should you decide to implement a USB host, a USB storage device interface (and potentially a file system atop of that), so having enough RAM can't be the show-stopper here.

If you have enough RAM, you can aggregate the data in it.

Also, you can talk to SD cards via SPI, so if you should choose to use SD cards (which sounds wise, seeing that they take care of wear leveling, and are incredibly cheap per Megabyte, but then again, you never told us how much data you need to keep in total), you can completely forgo the complex USB stack and just use a SPI-MMC/SD card driver from your favourite RTOS (FreeRTOS certainly has something like that), if your MCU doesn't come with an MMC/SD interface itself (some higher-end MCUs do).

\$\endgroup\$
5
  • \$\begingroup\$ Good comments, thank you. I guess sparing 0.5 MB RAM is doable on my Nucleo STM32H745. It also features USB OTG so I figured I could use that one for the SD card reader. If I bought an SPI SD card reader - how would I interface that to the PC ? \$\endgroup\$ – kellogs Jun 2 '20 at 9:29
  • \$\begingroup\$ you don't need an "SPI card reader". The SD card itself speaks SPI. You just directly connect the card to your MCU. You could simply remove the SD card and use it with your PC's SD card reader, or you could implement a USB mass storage device on your MCU that offers the content of your SD card to the PC. Where do the 0.5 MB come from? Is that your overall data amount? \$\endgroup\$ – Marcus Müller Jun 2 '20 at 9:30
  • \$\begingroup\$ At this point, it seems wise if you edited your question and actually explained what you need the storage for. Where the data comes from, why you need to store it on flash, what devices are involved. I'm kind of confused. \$\endgroup\$ – Marcus Müller Jun 2 '20 at 9:32
  • \$\begingroup\$ done. Are you saying I could run some wires to the SD card and start SPI-ing to it ? I could see some problems with that... \$\endgroup\$ – kellogs Jun 2 '20 at 9:41
  • \$\begingroup\$ yes, exactly that! Also, you shouldn't be doing that yourself, there's already drivers you can just use. \$\endgroup\$ – Marcus Müller Jun 2 '20 at 13:57
1
\$\begingroup\$

You can use SPI to write data directly to SD card, as @MarcusMüller suggested here. All you need is SD card socket, and later a USB reader to transfer from card to PC.

Alternatively you can use robust storage technology like FRAM to store data temporarily and then transfer it to PC via any interface you like.

The FRAM chips from Fujitsu (MB85RS4MT) or Cypress (CY15B104QSN) have 10^13-10^14 write cycles endurance, which does not require wear leveling, and they are much faster than Flash/EEPROM. In addition some of them support Quad-SPI interface, so if your MCU supports it they can be directly mapped to memory space.

\$\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.