1
\$\begingroup\$

I'm currently trying to run the SAM L21 as both a CDC and an MSD over USB. Thankfully there is example code here to get me started. I can move files into the on-board ram just like any other storage device. I can also send and receive data from a PC through a virtual COM Port created by the CDC code.

However, this is not the full implementation I have planned. I need to use a fat32 formatted SD card to save collected data. Usually one would connect an SD card to an MCU via SPI. However, I'm not sure that will work with my setup.

Can my MCU be made to write data over SPI into a fat formatted SD card? If this is possible, will the computer still recognize the SD card as formatted and usable?

If this is not possible with SPI, does anyone have experience integrating full SDC compatibility into an MCU? Links to documents or example code would be fantastic!

The end result will be a single usb connection that can sends and receive communication/data, as well as allow a user access to a formatted SD card for direct access to all data collected.

\$\endgroup\$
13
  • \$\begingroup\$ As long as you implement the filesystem on the MCU, sure. \$\endgroup\$ Commented Jun 15, 2016 at 18:36
  • 1
    \$\begingroup\$ You wouldn't typically have the MCU doing filesystem access at the same time as exposing the card to a PC over USB MSD. You're going to end up with filesystem errors that way. \$\endgroup\$
    – brhans
    Commented Jun 15, 2016 at 18:40
  • \$\begingroup\$ @IgnacioVazquez-Abrams So if I can find or create code to have the MCU write over SPI in this format, it could work? \$\endgroup\$
    – Nate San
    Commented Jun 15, 2016 at 19:00
  • \$\begingroup\$ "In this format" involves a lot more than just writing, but yes. And don't allow direct access to the card from the host; consider using something like MTP instead. \$\endgroup\$ Commented Jun 15, 2016 at 19:01
  • \$\begingroup\$ @brhans The inteneded application is to have all data transmitted from ram to the PC over the CDC serial port, and also save all that data on-board at the same time. The user will not access the MSD until all data collection is complete. \$\endgroup\$
    – Nate San
    Commented Jun 15, 2016 at 19:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.