Today we are starting a short series targeting SD memory cards. In this first example we are introducing users to the SD card using the custom SD card component. This component will expose simple API level commands to read from and write to the SD card. In this example we are targeting a 2gig SD memory card.
- PSoC 4 Pioneer Kit
- SD Card shield
- 2 gig SD card
Forum Post Attachments:
At the bottom of this post we are including the following items:
- Example Project Zip File
- Zip File of Images
- Project Schematic
- Component Configurations
- Custom Component Datasheet
The user can download the example project at the bottom of this post. The project uses the following list of Creator Components:
- SD Card
The components are configured by right clicking on the component in your Top Design schematic view and selecting Configure. Please enable the following selections in the Configuration windows for the listed components above.
The main.c firmware is included in the example project. Please review the commented sections for more details.
In this example we ship a custom SD card component and component datasheet to describe the functionality and available APIs and source files. The Component datasheet has been attached to this post. We have used so please refer to those examples for guidance. You will need to import the SD card component from the example project into your design if you want to use the custom component.
This SD card component uses the SPI interface to communicate to the SD card. The SPI interface is part of the SD card component and should be configured in the pin selections in the PSoC Creator DWR window.
In this example we show the user how to setup and initialize the SD card on the SD card shield. The remaining set of code in the example shows the user how to perform a number of common actions on the SD card:
- Write File
- Append File
- Read File
- Rename File
- Copy File
- Delete File
An important note before using the SD card, you will need to format the SD card prior to using it in this example. To format the SD card please navigate to the SD card web site to download the SDFormatter tool. Formatting the SD card is a one-time activity to enable it’s use. You will want to use a SD card reader or your SD card slot on your PC.
The SD card shield uses the 6 pin header for SPI communications. This header on the Pioneer board is, by default, not populated. You will need to solder on a 6 pin header to enable this connection. The Seeedstudio SD card reader uses the 6 pin header to communicate over SPI to the SD card. Once you have added this header connect the Seeedstudio shield to the Pioneer kit.
Test Your Project:
Program the example into the PSoC 4 kit. Edit and play around with the commented code to create new files. Then remove the SD card and plug into an SD card reader or PC that has an SD card port to verify the PSoC 4 actions.
I hope this example can help you in your design.