SD card file transfer via USB with lpc17xx

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SD card file transfer via USB with lpc17xx

1,752 Views
francobandini
Contributor I

Hi all,


I'm developing a board with the LPC1768 uC, with some peripherals and with one SD card.
Now I'm program with LPCXpresso on LPC1788 uC in "EA LPC1788 Eval Board PIC".
I have to write data into the SD card with uC (in a txt file) with the max transfer rate.
Then I have to read the SD card connecting a PC to the board by a USB connector.
Due to the enormous quantity of data stored in SD card after some days, I would transfer the data from SD card to PC at the maximun data rate.
I'd like to see my SD Card on my PC as "an external storage".
In other words when I insert USB cable (connecting my PC with the board), I'd like to see the SD Card as "an external hard disk", and see the files in sd card, without use teraterm or other terminal.
Is it possible with only LPC1768 uC or I should use an external USB controller to see on my PC the SD Card as an "external hard disk"?


Kind regards,
Franco Bandini.

0 Kudos
2 Replies

898 Views
sebastianhutten
Contributor II

Hi Franco,

Yes it is possible with LPC1768 although throughput could be limited by SPI interface (or does it support 4 bit I/F?).

I went through a similar exercise with a NXP Kinetis MCU (K22). I got a FatFs demo running that connected to SD card via SPI. Then I got a demo working that mounted a small RAMDISK as a USB Mass Storage Device (MSD) - aka Mass Storage Class (MSC). Merged these two demos and then figured out the glue code so MSC callbacks accessed the FatFs diskio API (instead of RAMDISK buffer). This also needed state logic to ensure one owner the FAT file system (host PC or local FatFs MCU). My app only starts the USB device when user select switch is in OFF/CONFIG position. The USB device is only stopped after MSC activity (E.g. events/callbacks) cease for 3s (e.g. user ejects the MSD). Only use FatFs to access the SD card when the USB device is stopped to ensure integrity of the FAT.

I used NXP SDK v2.x for this, but I don't think the LPCxxxx range is supported yet so you might have to look for other middleware (LPCOpen?). Or, as Zack said, MDK professional should also have all the middleware and drivers for this.

Since throughput is important to you, check if you MCU supports the 4 bit SD card interface  (e.g. SDIO, SDHC, MCI, etc.). Trick is to find middleware with file system support, drivers and and working demos. I have seen demos that mount SD card as MSD with 4-bit I/F but not for the MCU I was committed to. Even with such a demo you still need to merge USB MSC and to ensure single ownership of the FAT file system.

Hope this helps,

Sebastian

0 Kudos

898 Views
zackhavens
Contributor I

Hello Franco,

This is possible if you use the PC as a USB Host, and the LPC1788 as a USB Device.

For example, MDK-ARM toolchain from ARM's Keil team has a simple example of this setup called "USB Mass Storage Device" for the LPC1788 available in its Pack Installer. It uses MCI for a faster transfer rate, compared to SPI. The example requires an MDK-Plus or MDK Professional license to use. There is a seven day trial described at the following url:

Licensing User's Guide: MDK Professional Evaluation 

Thanks,
Zack Havens

0 Kudos