Documente Academic
Documente Profesional
Documente Cultură
• 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
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
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
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.
9
Some Definitions: “File System”
Data Structure that…
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
13
PSoCSD Connections (2.7-3.3V)
3.3V
3.3V
10k 10k 10k
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
PSoCSD Connections (5V)
3.3V 3.3V
5V
10k 10k 10k 330 330 330
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
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
Power On Detection
2. Card interface controller reset
O C R [31:0]
retrieves data O C R [31:0]
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: 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
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”
22
Additional Example Projects
• The following example projects are located within
PSoC Designer:
• 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