24
PSoC R Secure Digital (SD) Card Module Solution

PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

Embed Size (px)

Citation preview

Page 1: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

PSoCR

Secure Digital (SD) Card Module Solution

Page 2: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

2

Agenda

• SD Card Basics• Types of Media• Applications• Communication• File System

• SD Card Lab• Project 1: Run a short demo that prints the string

“Hello World” to the SD Card• Additional Example Projects

Page 3: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

SD Card Basics

Page 4: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

4

What is an SD Card?

High-capacity, inexpensive, portable flash (non-volatile) memory

• Capacity: 32MB to 2GB• Size: 11mm x 15mm x 1mm• Designed for fast and easy

transfer of data between devices

• Security for copyright protection on SD Cards

Page 5: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

5

PSoC + SD: Supported Media• SD

• 32mmx24mmx2.1mm• 2GB - $100 / 256MB - $20

• miniSD• Great for small electronics• 256MB - $35

• microSD/TransFlash• Smallest memory card available• 256MB - $35 / 2GB - $120

• MMC• Up to 8GB• 2GB - $50

• RS-MMC/MMCmobile• Popular for handsets • MMCmobile: Meets lower voltage spec of 1.8V

• HCSD • Capacity > 2GB

• SDIO• Extends functionality of devices with SD Card socket

Not Supported

Page 6: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

6

Where is SD Used?

• Digital Cameras (DSC, Video) • Media Players• Voice Recorders• PDA• PC Peripherals• GPS – Data Tracking• Mobile Handsets – Number and Setting Storage• Exercise Equipment – Storing Data• Bootloaders – Feed Data to Other Devices for

Programming• Shoes….

Page 7: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

7

Where is SD Used? PSoC Supported • Digital Cameras (DSC, Video) • Media Players• Voice Recorders• PDA• PC Peripherals• GPS – Data Tracking• Mobile Handsets – Number and Setting Storage• Exercise Equipment – Storing Data• Bootloaders – Feed Data to Other Devices for

Programming• Shoes….

Page 8: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

8

PSoC + SD: Required Resources

Digital Blocks Analog Blocks Flash RAM I/O

1 (DCB) 0 20kB 700 bytes 4-7

File System must be compatible with the build configuration (selectable parameter) of the User Module (UM)

• Several build configurations are available in the SDCard UM

Complex file systems require more flash• Must support additional addressing requirements • Full – 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 configuration• FAT16: Can use “Standard File System” or “Full File System” build configuration• Basic• Read Only• Basic Read Write

APIs removed from library source file reduced flash usage

No file system reduced flash usage

**Limited to only 29xxx family parts

Page 9: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

9

Why is so much Flash required?

• Implementing the file system to interface to SD Card requires sizeable Flash space • Most 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.

Page 10: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

10

Some Definitions: “File System”

Data Structure that…

• Stores and organizes computer files and data • Facilitates access to storage devices• Contains directories with subsets of filenames• Allows files to be searched, copied, renamed,

removed, etc.

Page 11: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

11

PSoC File System Compatibility

Compatible:• MS-DOS - Microsoft

• FAT16 • FAT32

NOT Compatible:• MS-DOS FAT12

• Limited availability• Requires more code space than FAT16• 3-bit nibbles

• HFS - Hierarchical File System• Apple Computer – MAC OS

• NTFS – New Technology File System• Windows NT• Windows 2000• Windows XP

Page 12: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

12

Some Definitions: “FAT”

• FAT: Disk structure that partitions blocks of contiguous space into clusters • Connects each file with an index into a file allocation table (FAT) • Clusters are typically 2 KB to 32 KB in size• Clusters contain groups of sectors which are 512 bytes in size • Each cluster may only link to one file at a time • Files typically contain many sectors or clusters • FAT entries correspond one for one with clusters• Each FAT entry points to the next FAT entry for the same file or

directory • A special value indicates the end of the file • The 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 Size Number of Clusters

FAT12 4,078

FAT16 65,518

FAT32 268,435,438

Page 13: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

13

PSoC + SD: Nuances

• Requires Short File Names (Dos8.3)• Saves code space• Generally longer file names are mapped to

other directories which aren’t supported

• Supports Only 1 Directory: Root Directory• More code is required to track directory paths• Flat-file system

• Speed Reduced with Multiple Files Open • More RAM needed for additional files

• Read/Write speed of ~2200 BYTES per second

• SPI mode instead of SD mode• Clock speed

• Two clock speed choices:• 24 MHz at 5V: 5% Performance Enhancement• 12 MHz at 3.3V

Limited by cache buffer size

Page 14: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

14

PSoCSD Connections (2.7-3.3V)

3

4

1

2

7

8

5

6

9

SD _R ES1

SD _M ISO

VSS

SD _SC LK

VC C

VSS

SD _M O SI

SD _C S

SD _R ES2

C O M SD _W P SD _C D

3.3V

3.3V

3.3V

SD _M ISO

SD _SC LK

SD _M O SI

SD _C S

SD _W P

SD _C D

10k 10k 10k

SD C ard

SD C ard Socket PSoC

Page 15: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

15

PSoCSD Connections (5V)

3

4

1

2

7

8

5

6

9

SD _R ES1

SD _M ISO

VSS

SD _SC LK

VC C

VSS

SD _M O SI

SD _C S

SD _R ES2

C O M SD _W P SD _C D

3.3V3.3V

5V

5V

SD _M ISO

SD _SC LK

SD _M O SI

SD _C S

SD _W P

SD _C D

10k 10k 10k 330 330 330

SD C ard

SD C ard Socket PSoC

Page 16: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

16

SD Card Communication: 2 Types

• SD Mode• Clock• 4 Bidirectional Data Lines

• SPI Mode (PSoC Supported)• Clock• Card Select (Slave Select)• 2 Unidirectional Data Lines

PSoC SD C ard

SC LKD 0D 1D 2

SC LKD 0D 1D 2

D 3 D 3

PSoC SD C ard

SC LKM ISOM O SI

SS1

SC LKM ISOM O SISS1

Page 17: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

17

SD Internals

• PSoC implements the file system:

1. PSoC supplies a command to the card interface controller in order to read from or write to files on the SD card

2. Card interface controller retrieves data

3. PSoC completes calculations to determine further necessary commands

D AT2C D /D AT2

C M D C LK D AT0D AT1

Interface D river

VDD

C ardInterfaceC ontro ller

O C R [31:0 ]

O C R [31:0 ]

O C R [31:0 ]

O C R [31:0 ]

O C R [31:0 ]

O C R [31:0 ]

Pow

er O

n D

etec

tion

M em ory C ore Interface reset

reset

M em ory C ore

Page 18: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

SD Card Lab

Page 19: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

19

Lab 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.3V1. Insert jumper JP3 to

regulate voltage to 3.3V

2. Remove the following jumpers: • JP2: Connects P27 to TX pin • JP1: Connects P16 to RX pin

Page 20: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

20

Lab Hardware: SDUSB

• CY3210-SDCARD Kit also contains

• SD Card Reader/Writer with USB connection

• 64 MB SD Card

• Connect Reader/Writer to PC and insert SD Card to read

*Note: Additional projects located in PSoC Designer Examples directory

Page 21: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

21

Lab Software: You Need to Install…

• PSoC Designerwww.cypress.com/psocdesigner• PSoC Expresswww.cypress.com/psocexpress• PSoC Programmerwww.cypress.com/psocprogrammer• Latest User Module (UM) Extension Packwww.cypress.com/ep_NewUM

Page 22: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

22

Project 1: “Hello World” Quick Example

Build Project• Insert SD Card Adapter board into LCD connector

on CY3210-PSoCEval1 board (as shown)• Put CY8C29466-24PXI PSoC device into 28-pin

PDIP socket• Open “Hello World” project from PSoC Designer

in the following directory:C:\ProgramFiles\CypressMicrosystems\ PSoCDesigner\Examples\SDCard\Hello

• Generate application, build and program part• Connect 12V power supply to voltage regulator on

PSoCEval1 board

Run Project• Insert SD Card into SD Card Adapter board’s

socket• PSoC writes “Hello World” to SD Card• Remove SD Card• Place SD Card in USB Thumb Drive• Read “hello.txt”

*Note: Using MiniProg to program will supply the entire PSoCEVAL1 board 5V. Remove SD

Cardfrom Adapter board before using MiniProg.

Page 23: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

23

Additional Example Projects

• The following example projects are located within PSoC Designer:

C:\Program Files\Cypress MicroSystems\PSoC Designer\Examples\SDCard

• AppendFile - 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.

Page 24: PSoC R Secure Digital (SD) Card Module Solution. 2 Agenda SD Card Basics Types of Media Applications Communication File System SD Card Lab Project 1:

24

Resources

• SD Card Physical Layer Specification www.sdcard.org

• MMC Card Physical Layer Specificationwww.mmca.org