Sunteți pe pagina 1din 24

PSoCR

Secure Digital (SD)


Card Module
Solution
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

2
SD Card Basics
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

4
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 Not Supported
• SDIO
• Extends functionality of devices with SD Card socket

5
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….

6
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….

7
PSoC + SD: Required Resources
Digital Blocks Analog Blocks Flash RAM I/O

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

**Limited to only 29xxx family parts

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 APIs removed from library source file  reduced flash usage
• Read Only
• Basic Read Write No file system  reduced flash usage

8
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.

9
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.

10
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

11
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
12
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 Limited by cache
buffer size
• 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

13
PSoCSD Connections (2.7-3.3V)

3.3V
3.3V
10k 10k 10k

S D C ard S ocket PSoC


S D _R E S 2 9
S D _C S 1 S D _C S

S D _M O S I 2 S D _M O S I

VSS 3
S D C ard VCC 4
3.3V
S D _S C LK 5 S D _S C LK

VSS 6
S D _M IS O 7 S D _M IS O

S D _R E S 1 8
S D _C D
COM S D _W P S D _C D
S D _W P

14
PSoCSD Connections (5V)

3.3V 3.3V
5V
10k 10k 10k 330 330 330

S D C ard S ocket PSoC


S D _R E S 2 9
S D _C S 1 S D _C S

S D _M O S I 2 S D _M O S I

VSS 3
S D C ard VCC 4
5V
S D _S C LK 5 S D _S C LK

VSS 6
S D _M IS O 7 S D _M IS O

S D _R E S 1 8
S D _C D
COM S D _W P S D _C D
S D _W P

15
SD Card Communication: 2 Types
• SD Mode SC LK
D0
SC LK
D0
D1 D1
• Clock D2
D3
D2
D3

• 4 Bidirectional Data Lines


PSoC SD C ard

• SPI Mode (PSoC Supported)


• Clock SC LK SC LK

• Card Select (Slave Select) M ISO


M O SI
SS1
M ISO
M O SI
SS1

• 2 Unidirectional Data Lines PSoC SD C ard

16
SD Internals
• PSoC implements the file

VDD
system:
D A T2 CMD C LK D A T0
C D /D A T2 D A T1
1. PSoC supplies a command to Interface D river

the card interface controller in O C R [31:0]


order to read from or write to O C R [31:0] C ard
files on the SD card O C R [31:0] Interface
C ontroller
O C R [31:0]

Power On Detection
2. Card interface controller reset
O C R [31:0]
retrieves data O C R [31:0]

3. PSoC completes calculations


to determine further necessary M em ory C ore Interface reset

commands

M em ory C ore

17
SD Card Lab
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.3V
1. 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

19
Lab Hardware: SDUSB
• 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

20
Lab Software: You Need to Install…
• PSoC Designer
www.cypress.com/psocdesigner
• PSoC Express
www.cypress.com/psocexpress
• PSoC Programmer
www.cypress.com/psocprogrammer
• Latest User Module (UM) Extension Pack
www.cypress.com/ep_NewUM

21
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 Card
from Adapter board before using MiniProg.

22
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.

23
Resources
• SD Card Physical Layer Specification
www.sdcard.org
• MMC Card Physical Layer Specification
www.mmca.org

24

S-ar putea să vă placă și