Micro SD Card
Command
SD_CMD55
SD_CMD56
SD_CMD58
SD_CMD59
Description
Defines the next command
Used either to transfer a Data Block or to get a Data Block
Reads the OCR register of a card
Turns the CRC option on or off
9.2 SD Card Initialization
To use an SD Card it is necessary to follow a specific sequence for initialization. The first step is to set the SPI clock. The MCU
must then send 80 clock signals before it starts communication. This allows initialization of all the registers. The slave pin is
configured at zero with this value the MCU enters SPI mode and a CRC byte is sent. After the configuration, the MCU starts
to check the block length and place the clock to maximum.
Figure 21. Initialization flowchart
SD.c file
As explained in Figure 21, the SD Card initialization is executed with the SD_init function. The slave is enabled and disabled.
Delays are generated prior verifying the IDLE command. The MCU sends a byte that contains information to send the argument
and the CRC waits for a response from the slave device.
The card is continuously polled with initialization and block-length commands until the idle bit becomes clear, indicating that
the card is fully initialized and ready to respond to general commands.
For more information about SD Card communication, Freescale provides the design reference manual titled SD Card Reader
Using the M9S08JM60 Series Designer Reference Manual (document DRM104).
Table 7. SD Card function
Functions
Parameters
Functionality
SD_Read_Block(UINT32
u16SD_Block,UINT8 *pu8Data-
Pointer)
u16SD_Block—Indicates the block to read. *pu8 Reads an SD Card block and if an
DataPointer—Base pointer to store the data from error occurs a code returns
the SD Card.
SD_Write_Block(UINT32
u16SD_Block,UINT8 *pu8Data-
Pointer)
UINT32 u16SD_Block—Indicates the block to b Writes one SD Card block and if an
write. UINT8 *pu8DataPointer—Base pointer to
error occurs a code returns.
store the data to SD Card.
9.3 Stored Information
The code below shows how to use the SD.c functions that store diagnostic information (glucose levels and blood pressure) with
different data. Each diagnose is saved differently. For example, the blood pressure diagnostic saves the systolic pressure, diastolic
pressure, and the heart beats taken.
Implementing a Glucometer and Blood Pressure Monitor Medical Devices, Rev. 1, 4/2010
22
Freescale Semiconductor, Inc.