Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SD/MMC/SDIO Card Example

Purpose

This example demonstrates basic functions of SD/MMC/SDIO stack. It will read and write an SD, MMC or SDIO card over MCI or SPI interface. It is a development base for a SDIO application or a specific SD/MMC application which does not require a file system.

Description

The example executes the following sequences:

  • For each card slot available on board:
    • Wait for a card insertion
    • Initialize an SD, MMC or SDIO card.
    • If the inserted card is an SD or MMC card, test read/write access.
      • Write data into the card
      • Read data from the card
      • Verify the written data.
    • If the inserted card is a SDIO card:
      • Iniltialize a SDIO card.
      • Read and write test on CIA.

The example outputs the information through the standard output (stdio). To know the output used on the board, look in the conf_example.h file and connect a terminal to the correct stdio port.

While using SAM4L Xplained Pro or SAM4L8 Xplained Pro, please attach IO1 Xplained Pro extension board to EXT1.

While using Xplained Pro evaluation kits, please attach I/O1 Xplained Pro extension board to EXT1.

Usage

  1. Build the program and download it into the board.
  2. On the computer, open and configure a terminal application. Refer to conf_example.h file.
  3. Start the application.
  4. In the terminal window, the following text should appear:
    -- SD/MMC/SDIO Card Example --
    -- Compiled: xxx xx xxxx xx:xx:xx --
    Please plug an SD, MMC or SDIO card in slot 1.
    !!Warning, the data contained will be lost!!
  5. If the inserted card is a SD or MMC card, the following text should appear:
    A card has been connected.
    Card information:
    xxxx
    xxxx MB
    Write pattern... XXXXKBps [OK]
    Read... XXXXKBps [OK]
    Read and check pattern... [OK]
    Test finished, please unplugged card.
  6. If inserted card is a SDIO card, similar following text should appear:
    A card has been connected.
    Card information:
    SDIO
    0MB
    --- Test with direct read and write command of CIA:
    Dump buffer (length=22):
    0: 11 00 00 00 00 00 00 00 17 00 10 00 00 00 00 00
    10: 00 00 01 00 00 00
    Write 0x02 to IEN(CIA.4).
    Check IEN after write:0x02
    Test OK
    --- Test with extended read and write command of CIA:
    Dump buffer (length=22):
    0: 11 00 00 00 00 00 00 00 17 00 10 00 00 00 00 00
    10: 00 00 01 00 00 00
    Modify Some R/W bytes (2,4) for FN0 and write:
    Check CIA after write:
    Dump buffer (length=22):
    0: 11 00 00 00 03 00 00 00 17 00 10 00 00 00 00 00
    10: 00 00 01 00 00 00
    test OK
    All test done.