Overview
The SDHC SdCard Example application demonstrates the use of SD card driver. It displays the card information followed by a write-read compare test and the erase operation. Provide an example with different modes:
- Detect card inserted
- Read and write single block and multi-blocks to sdcard
- Erase blocks in sdcard
Supported Platforms
These Freescale Freedom development platforms and Tower System modules are supported by the SDHC SdCard example.
- TWR-K21F120M
- TWR-K60D100M
- TWR-K64F120M
- TWR-K65F180M
System Requirement
Hardware requirements
- J-Link ARM
- P&E Micro Multi-link universal
- Mini/micro USB cable
- USB A to micro AB cable
- Hardware (tower/base board, ...) for specific device
- Personal Computer
Toolchain requirements
- IAR embedded Workbench version 7.30.4
- ARM GCC 4.8.3 2014q3
- Keil MDK 5.13
- Kinetis Design Studio IDE v.2.5.0
- Atollic TrueSTUDIO for ARM win32 v5.2.1
Software requirements
- The project files are in: <SDK_Install>/examples/<board>/driver_examples/sdhc_sdcard/<toolchain>.
- Library dependencies: ksdk_platform_lib
Getting Started
Hardware settings
The SDHC SdCard Example project does not call for any special hardware configurations. Although not required, the recommendation is to leave the development board's jumper settings and configurations in default state when running this example.
Prepare the example
- Connect a USB cable between the PC host and the OpenSDA USB port on the board.
- Open a serial terminal with these settings:
- 115200 baud rate
- 8 data bits
- No parity
- One stop bit
- No flow control
- Download the program to the target board.
- Either press the reset button on your board or launch the debugger in your IDE to begin running the example.
Run the example
Insert an SD or a micro-SD card depending on the board connector. Ensure that the card doesn't contain any important content because the demo will erase and overwrite some sectors.
These instructions are displayed/shown on the terminal window:
SD Card Demo Start!
This demo is going to access data on card
A card is detected
sdcard initialized
------- Card Information -------
Card Type: SDHC
Card Capacity: f GB
Host Clock Max Rate: 120 MHz
Clock Rate: 20 MHz
Manufacturer ID: 0x3
OEM ID: 0x5344
Product name: SD04G
Product serial number: 0x25BD9A0
Product revision: 8.0
Manufacturing data: Dec 2010
CSD Structure: 0x1
taac: f ns
nsac: 0 clks
tran speed: f kbps
ccc: class 0 2 4 5 7 8 10
max read block length: 512 Bytes
c_size: 7562
Erase unit size is one or multiple units of 512 bytes
The size of write protected group is 2 blocks
R2W_Factor: 2
max write block length: 9
The content is copied
Hard disk-like file system with partition table
SCR Structure: 0x0
SD Spec: 0x2
SD Spec 3.0
SDHC Card(Security Version 2.00)
Card supports 1-bit bus width
Card supports 4-bit bus width
Support set block count command
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
THIS DEMO IS GOING TO ERASE AND WRITE RAW DATA TO THE CARD,
MAKE SURE YOU TAKE BACKUP OF ANY VALUEABLE DATA PRESENT IN THE CARD
BEFORE PROCEEDING.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Do you want to proceed? (Enter 'y' IF yes) :
User need type 'Y' character from the keyboard. These instructions are displayed/shown on the terminal window:
Start write/read/compare demo...
Single block write/read/compare demo passed!
Multi-block write/read/compare demo passed!
Erase blocks demo passed!
SD Card Demo End!