2Agenda SD Card Basics SD Card Lab Types of Media Applications CommunicationFile SystemSD Card LabProject 1: Run a short demo that prints the string “Hello World” to the SD CardAdditional Example Projects
4What is an SD Card?High-capacity, inexpensive, portable flash (non-volatile) memoryCapacity: 32MB to 2GBSize: 11mm x 15mm x 1mmDesigned for fast and easy transfer of data between devicesSecurity for copyright protection on SD Cards
5PSoC + SD: Supported Media 32mmx24mmx2.1mm2GB - $100 / 256MB - $20miniSDGreat for small electronics256MB - $35microSD/TransFlashSmallest memory card available256MB - $35 / 2GB - $120MMCUp to 8GB2GB - $50RS-MMC/MMCmobilePopular for handsetsMMCmobile: Meets lower voltage spec of 1.8VHCSDCapacity > 2GBSDIOExtends functionality of devices with SD Card socketNot Supported
6Where is SD Used? Digital Cameras (DSC, Video) Media Players Voice RecordersPDAPC PeripheralsGPS – Data TrackingMobile Handsets – Number and Setting StorageExercise Equipment – Storing DataBootloaders – Feed Data to Other Devices for ProgrammingShoes….
7Where is SD Used? PSoC Supported Digital Cameras (DSC, Video)Media PlayersVoice RecordersPDAPC PeripheralsGPS – Data TrackingMobile Handsets – Number and Setting StorageExercise Equipment – Storing DataBootloaders – Feed Data to Other Devices for ProgrammingShoes….
8PSoC + SD: Required Resources Digital BlocksAnalog BlocksFlashRAMI/O1 (DCB)20kB700 bytes4-7**Limited to only 29xxx family partsFile System must be compatible with the build configuration (selectable parameter) of the User Module (UM)Several build configurations are available in the SDCard UMComplex file systems require more flashMust support additional addressing requirementsFull – Additional addresses require more flash (How much on average?)Standard – Complete API list is loaded into library source file (How much do you save by using FAT16/Standard option?)Build Configuration Options:FAT32: Must use “Full File System” build configurationFAT16: Can use “Standard File System” or “Full File System” build configurationBasicRead OnlyBasic Read WriteAPIs removed from library source file reduced flash usageNo file system reduced flash usage
9Why is so much Flash required? Implementing the file system to interface to SD Card requires sizeable Flash spaceMost cards are formatted with FAT32 (Generally 32MB and greater)- Full file system build configuration.**FAT32 is a more complex file system, and requires more flash to support additional addresses available in the card.The FAT32 file system has more address space which requires more flash than the FAT16 file system. Both these file systems include the same API functions.The other build configurations reduce the size of flash needed by offering SD Card communication options with more limited capabilities.
10Some Definitions: “File System” Data Structure that…Stores and organizes computer files and dataFacilitates access to storage devicesContains directories with subsets of filenamesAllows files to be searched, copied, renamed, removed, etc.
11PSoC File System Compatibility Compatible:MS-DOS - MicrosoftFAT16FAT32NOT Compatible:MS-DOS FAT12Limited availabilityRequires more code space than FAT163-bit nibblesHFS - Hierarchical File SystemApple Computer – MAC OSNTFS – New Technology File SystemWindows NTWindows 2000Windows XP
12Some Definitions: “FAT” FAT: Disk structure that partitions blocks of contiguous space into clustersConnects each file with an index into a file allocation table (FAT)Clusters are typically 2 KB to 32 KB in sizeClusters contain groups of sectors which are 512 bytes in sizeEach cluster may only link to one file at a timeFiles typically contain many sectors or clustersFAT entries correspond one for one with clustersEach FAT entry points to the next FAT entry for the same file or directoryA special value indicates the end of the fileThe size of FAT entries dictates the size of the FAT and the maximum size of the disk. There are 3 common FAT entry sizes in use:FAT Entry SizeNumber of ClustersFAT124,078FAT1665,518FAT32268,435,438
13PSoC + SD: Nuances Limited by cache buffer size Requires Short File Names (Dos8.3)Saves code spaceGenerally longer file names are mapped to other directories which aren’t supportedSupports Only 1 Directory: Root DirectoryMore code is required to track directory pathsFlat-file systemSpeed Reduced with Multiple Files OpenMore RAM needed for additional filesRead/Write speed of ~2200 BYTES per secondSPI mode instead of SD modeClock speedTwo clock speed choices:24 MHz at 5V: 5% Performance Enhancement12 MHz at 3.3VLimited by cache buffer size
16SD Card Communication: 2 Types SD ModeClock4 Bidirectional Data LinesSPI Mode (PSoC Supported)Card Select (Slave Select)2 Unidirectional Data Lines
17SD Internals PSoC implements the file system: PSoC supplies a command to the card interface controller in order to read from or write to files on the SD cardCard interface controller retrieves dataPSoC completes calculations to determine further necessary commands
19Lab Hardware: CY3210-SDCARD SD Card Adapter board (3.3V) is compatible with the LCD connector on the CY3210-PSoCEVAL1 board (shown)To properly supply SD Card Adapter board with 3.3VInsert jumper JP3 to regulate voltage to 3.3VRemove the following jumpers:JP2: Connects P27 to TX pinJP1: Connects P16 to RX pin
20Lab Hardware: SDUSB CY3210-SDCARD Kit also contains SD Card Reader/Writer with USB connection64 MB SD CardConnect Reader/Writer to PC and insert SD Card to read*Note: Additional projects located in PSoC Designer Examples directory
21Lab Software: You Need to Install… PSoC DesignerPSoC ExpressPSoC ProgrammerLatest User Module (UM) Extension Pack
22Project 1: “Hello World” Quick Example Build ProjectInsert SD Card Adapter board into LCD connector on CY3210-PSoCEval1 board (as shown)Put CY8C PXI PSoC device into 28-pin PDIP socketOpen “Hello World” project from PSoC Designer in the following directory: C:\ProgramFiles\CypressMicrosystems\ PSoCDesigner\Examples\SDCard\HelloGenerate application, build and program partConnect 12V power supply to voltage regulator on PSoCEval1 boardRun ProjectInsert SD Card into SD Card Adapter board’s socketPSoC writes “Hello World” to SD CardRemove SD CardPlace SD Card in USB Thumb DriveRead “hello.txt”*Note: Using MiniProg to program will supply the entire PSoCEVAL1 board 5V. Remove SD Cardfrom Adapter board before using MiniProg.
23Additional Example Projects The following example projects are located within PSoC Designer: C:\Program Files\Cypress MicroSystems\PSoC Designer\Examples\SDCardAppendFile - Open a file and write string to a file. Also print file’s size out the serial port.ListFiles - When card is inserted in the SD socket, the file’s names and their sizes will be printed via the serial port.SdCopyFile - Creates a file then copies it to another file.UartLog - This application requires the use of a terminal emulator. It will log data to the SD Card until a line with a period "." in the first character location is detected.UartRead - Open a specific file and display its contents via a serial port.