You are on page 1of 6

CYPRESS PSoC5 SD CARD Component

Features:
Supports SDSC and SDHC cards Mode of communication is through SPI Compliant with SD 2.0 specification Data read rate up to 7Mbps* and data write rate 6 Mbps*

General Description: SD Card (Secure Digital Card) is an ultra small flash memory card designed to provide high-capacity memory in a small size. There are two types of SD cards namely SDSC(Standard Capacity) and SDHC(High Capacity). SDSC has a maximum storage capacity up to 2 GB whereas SDHC has a maximum storage capacity up to 32GB. When To use SD Component: The SD component should be used whenever PSoC device wants to store or access data from off-the-shelf non-volatile memory like SD card. With SD card sizes reaching as high as 32 GBytes, this component enables PSoC to be used in wider range of applications.

* - It is applicable only in the case of multiple block read/write.

Input/Output Connections: This section describes input and output connections for the SD card component.

Figure 1: Schematic Diagram of SD component

D0 Input: The D0 carries the Master In Slave Out (MISO) signal from a slave(SD card) device. CMD Output : The CMD carries the Master Out Slave In (MOSI) signal from the PSoC device. D3 Output: It carries the Slave Select (SS) signal to the slave device. CLK Output: The CLK signal carries the Serial Clock (SCLK) signal. It provides the master synchronization clock output to the slave device(s) on the bus.

Application Programming Interface : Application Programming Interface (API) routines allows user to configure the SD component using C functions at run time. The following table lists and describes the interface to each function. The subsequent sections cover each function in more detail. By default, PSoC Creator assigns the instance name "SD_1" to the first instance of a component in a given design. User can rename the instance to any unique value that follows the syntactic rules for identifiers. The instance name becomes the prefix of every global function name, variable, and constant symbol for the instance. For readability, the instance name used in the following table is "SD_1".

Table SD_1_Init SD_1_Start SD_1_writeSingleBlock SD_1_readSingleBlock SD_1_writeMultipleBlocks SD_1_readMultipleBlocks SD_1_Erase

Description Should be called the first time the component is started Starts the operations of SD card To write sector/block to SD card To read sector/block from SD card To write sectors/blocks to SD card To read sectors/blocks from SD card To erase sector(s) from SD card

uint8 SD_1_Init() Description : Should be called the first time the component is started. Parameters : None Return Value: 0 - On success 1 On failure .

uint8 SD_1_Start() Description : Starts the operations of SD card Parameters : None Return Value: 0 - Initialization successful 1 - Card not present 2 - Card do not match VDD range 3 Initialization failed

uint8 SD_1_writeSingleBlock(uint32 block_addr, uint8 buffer[] ) Description : Writes sector/block to SD card . Parameters : uint32 block_addr : Starting block address to write from. uint8 buffer[] : Buffer to be written to SD card. Size of the buffer must be 512 Bytes Return Value: 0 - On success 1 On failure . 2 Write protected. uint8 SD_1_readSingleBlock(uint32 block_addr,uint8 buffer[] ) Description : Reads sector/block from SD card . Parameters : uint32 block_addr : Starting block address to read from. uint8 buffer[] : Buffer to store, after reading from SD card. Size of the buffer must be 512 bytes. Return Value: 0 - On success 1 - On failure . uint8 SD_1_writeMultipleBlocks(uint32 block_addr, uint32 no_of_blocks, uint8 buffer[] ) Description : Write sectors/blocks to SD card . It writes sectors from 'block_addr' to 'block_addr + (no_of_blocks - 1) ' Parameters : uint32 block_addr : Starting block address to write from.

uint32 no_of_blocks : Number of blocks to write. uint8 buffer[] : Size of the buffer must be no_of_blocks * 512. Return Value: 0 - On success 1 - On failure . uint8 SD_1_readMultipleBlocks(uint32 block_addr, uint32 no_of_blocks, uint8 buffer[] ) Description : Read sectors/blocks from SD card . It reads sectors from 'block_addr' to 'block_addr + (no_of_blocks - 1) ' Parameters : uint32 block_addr : Starting block address to read from. uint32 no_of_blocks : Number of blocks to read. uint8 buffer[] : Size of the buffer must be no_of_blocks * 512. Return Value: 0 - On success 1 - On failure uint8 SD_1_Erase(uint32 block_addr, uint32 no_of_blocks ) Description : Erases sector(s) from SD card . It erases from sector number 'block_addr' to 'block_addr + no_of_blocks'. After Erase, respective locations will replaced with '0' Parameters : uint32 block_addr : starting block address to erase. uint32 no_of_blocks : Number of blocks to erase. Return Value: 0 - On success 1 - On failure

You might also like