Hi all,
I'm developing a board with the LPC1768 microcontroller, with some peripherals and finally with one SD card. I have to write data into the SD card, so which is the best mode to do this with the max transfer rate?
Then I have to read the SD card connecting a personal computer 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. Can I use the LPC1768 as a USB controller? If yes, how can I do this? And which is the data rate? If is not possible to use the LPC1768 to read data from the SD card at high speed, how can I share the lines of SD card between LPC1768 and another device (controller)?
Thanks
Stefano
Hi Stefano,
Overall, what you describe is possible with the LPC1768. The 1768 does not have an SD/MMC peripheral, so you'd need to access the card using a standard SPI port. This would not give optimal transfer rate since SPI is a serial transfer versus the 4/8-bit data bus provided by an SD/MMC peripheral (e.g. the LPC177x/8x, LPC18xx, LPC43xx etc has SD/MMC interface).
There are various file system software components out there that you can use to read/write the card in a FAT file format. I see many folks using the FatFs component, and I've seen it included within in the LPC open distributions. Also see https://www.lpcware.com/content/nxpfile/an10916-fat-library-efsl-and-fatfs-port-nxp-lpc1700
You are correct, the LPC1768 can be used as a USB mass storage device, which provides a PC (or another other USB host) access to the SD card. As for sharing the lines of the SD card, you don't really do that. You have one SPI port attached to the physical card, then the LPC app needs to switch access to the card between itself and the attached USB host. The attached USB host will access the card as a raw block device, and it will manage the file system on the card, thus the LPC app cannot write the card at the same time. Typically, you have an arrangement where the LPC app can have the card while there is no USB. Then, when the USB is attached, the LPC app can either give the USB host access to the card, or it can indicate to the USB host that the card is unavailable (same as card not inserted). In the end, only one app at a time gets to mount and access the card.
You mentioned maximum transfer rate several times, and I don't have actual rate numbers, but be aware that using SPI to access the card is not as fast as using a 4/8-bit data bus. Also note that the LPC1768 has a full speed (12Mbit/s), not high speed (480Mbit/s), USB peripheral.
Best Regards,
Tyler Drazich