30. SD/SDIO/MMC card host interface (SDMMC)

30.1 SDMMC main features

The SD/SDIO MMC card host interface (SDMMC) provides an interface between the APB2 peripheral bus and MultiMediaCards (MMCs), SD memory cards and SDIO cards.

The MultiMediaCard system specifications are available through the MultiMediaCard Association website, published by the MMCA technical committee.

SD memory card and SD I/O card system specifications are available through the SD card Association website.

The SDMMC features include the following:

  1. Note:
    1. 1 The SDMMC does not have an SPI-compatible communication mode.
    2. 2 The SD memory card protocol is a superset of the MultiMediaCard protocol as defined in the MultiMediaCard system specification V2.11 . Several commands required for SD memory devices are not supported by either SD I/O-only cards or the I/O portion of combo cards. Some of these commands have no use in SD I/O devices, such as erase commands, and thus are not supported in the SDIO protocol. In addition, several commands are different between SD memory cards and SD I/O cards and thus are not supported in the SDIO protocol. For details refer to SD I/O card Specification Version 1.0 .

The MultiMediaCard/SD bus connects cards to the controller.

The current version of the SDMMC supports only one SD/SDIO/MMC4.2 card at any one time and a stack of MMC4.1 or previous.

30.2 SDMMC bus topology

Communication over the bus is based on command and data transfers.

The basic transaction on the MultiMediaCard/SD/SD I/O bus is the command/response transaction. These types of bus transaction transfer their information directly within the command or response structure. In addition, some operations have a data token.

Data transfers to/from SD/SDIO memory cards are done in data blocks. Data transfers to/from MMC are done data blocks or streams.

Figure 397. “No response” and “no data” operations

Timing diagram for 'No response' and 'no data' operations. It shows two command-response sequences on the SDMMC_CMD line. The first sequence is labeled 'Operation (no response)' and shows a command being sent but no response received. The second sequence is labeled 'Operation (no data)' and shows a command being sent and a response received, but no data transferred on the SDMMC_D line.

Figure 397 illustrates two types of operations on the SDMMC interface. The first operation, labeled "Operation (no response)", shows a command being sent from the host to the card(s) via the SDMMC_CMD line, but no response is received. The second operation, labeled "Operation (no data)", shows a command being sent from the host to the card via the SDMMC_CMD line, a response is received from the card to the host, but no data is transferred on the SDMMC_D line.

Timing diagram for 'No response' and 'no data' operations. It shows two command-response sequences on the SDMMC_CMD line. The first sequence is labeled 'Operation (no response)' and shows a command being sent but no response received. The second sequence is labeled 'Operation (no data)' and shows a command being sent and a response received, but no data transferred on the SDMMC_D line.

Figure 398. (Multiple) block read operation

Timing diagram for multiple block read operation. It shows a 'Block read operation' where a command is sent, a response is received, and multiple 'Data block | crc' units are transferred from the card to the host on the SDMMC_D line. This is followed by a 'Multiple block read operation' which includes a 'Stop command' sent to the host, a response, and a final 'Data block | crc' transfer. A note indicates that the stop command stops data transfer.

Figure 398 illustrates a multiple block read operation. It starts with a "Block read operation" where a command is sent from the host to the card via the SDMMC_CMD line, a response is received from the card to the host, and multiple data blocks (each consisting of a data block and a CRC) are transferred from the card to the host via the SDMMC_D line. This is followed by a "Multiple block read operation" which includes a "Stop command" sent from the host to the card via the SDMMC_CMD line, a response is received from the card to the host, and a final data block (consisting of a data block and a CRC) is transferred from the card to the host via the SDMMC_D line. A note indicates that the stop command stops data transfer.

Timing diagram for multiple block read operation. It shows a 'Block read operation' where a command is sent, a response is received, and multiple 'Data block | crc' units are transferred from the card to the host on the SDMMC_D line. This is followed by a 'Multiple block read operation' which includes a 'Stop command' sent to the host, a response, and a final 'Data block | crc' transfer. A note indicates that the stop command stops data transfer.

Figure 399. (Multiple) block write operation

Timing diagram for multiple block write operation. It shows a 'Block write operation' where a command is sent, a response is received, and a 'Data block | crc' is transferred from the host to the card on the SDMMC_D line, followed by a 'Busy' signal from the card. This is followed by a 'Multiple block write operation' which includes a 'Stop command' sent to the host, a response, another 'Data block | crc' transfer, and another 'Busy' signal. A note indicates that the stop command stops data transfer.

Figure 399 illustrates a multiple block write operation. It starts with a "Block write operation" where a command is sent from the host to the card via the SDMMC_CMD line, a response is received from the card to the host, and a data block (consisting of a data block and a CRC) is transferred from the host to the card via the SDMMC_D line, followed by a "Busy" signal from the card. This is followed by a "Multiple block write operation" which includes a "Stop command" sent from the host to the card via the SDMMC_CMD line, a response is received from the card to the host, another data block (consisting of a data block and a CRC) is transferred from the host to the card via the SDMMC_D line, and another "Busy" signal from the card. A note indicates that the stop command stops data transfer.

Timing diagram for multiple block write operation. It shows a 'Block write operation' where a command is sent, a response is received, and a 'Data block | crc' is transferred from the host to the card on the SDMMC_D line, followed by a 'Busy' signal from the card. This is followed by a 'Multiple block write operation' which includes a 'Stop command' sent to the host, a response, another 'Data block | crc' transfer, and another 'Busy' signal. A note indicates that the stop command stops data transfer.

Note: The SDMMC will not send any data as long as the Busy signal is asserted (SDMMC_D0 pulled low).

Figure 400. Sequential read operation

Figure 400. Sequential read operation timing diagram showing SDMMC_CMD and SDMMC_D signals. It details the command, response, and data stream phases for a read operation, ending with a stop command.

The diagram illustrates the timing for a sequential read operation. On the SDMMC_CMD line, a 'Command' is sent 'From host to card(s)', followed by a 'Response' 'From card to host'. On the SDMMC_D line, a 'Data stream' is sent 'Data from card to host'. This entire phase is labeled 'Data transfer operation'. To end the transfer, a 'Stop command' is sent 'From host to card(s)' on the SDMMC_CMD line, followed by a 'Response'. This final phase is labeled 'Data stop operation' with the note 'Stop command stops data transfer'. Diagram reference: ai14738b.

Figure 400. Sequential read operation timing diagram showing SDMMC_CMD and SDMMC_D signals. It details the command, response, and data stream phases for a read operation, ending with a stop command.

Figure 401. Sequential write operation

Figure 401. Sequential write operation timing diagram showing SDMMC_CMD and SDMMC_D signals. It details the command, response, and data stream phases for a write operation, ending with a stop command.

The diagram illustrates the timing for a sequential write operation. On the SDMMC_CMD line, a 'Command' is sent 'From host to card(s)', followed by a 'Response' 'From card to host'. On the SDMMC_D line, a 'Data stream' is sent 'Data from host to card'. This phase is labeled 'Data transfer operation'. To end the transfer, a 'Stop command' is sent 'From host to card(s)' on the SDMMC_CMD line, followed by a 'Response'. This final phase is labeled 'Data stop operation' with the note 'Stop command stops data transfer'. Diagram reference: ai14739b.

Figure 401. Sequential write operation timing diagram showing SDMMC_CMD and SDMMC_D signals. It details the command, response, and data stream phases for a write operation, ending with a stop command.

30.3 SDMMC functional description

The SDMMC consists of two parts:

Figure 402. SDMMC block diagram

Figure 402. SDMMC block diagram showing the internal components: APB2 interface and SDMMC adapter, and their external connections.

The block diagram shows the internal structure of the SDMMC. It contains an APB2 interface block and an SDMMC adapter block. The APB2 interface connects to the 'APB2 bus' and outputs 'Interrupts and DMA request'. The SDMMC adapter connects to external signals: 'SDMMC_CK', 'SDMMC_CMD', and 'SDMMC_D[7:0]'. The entire block is clocked by 'PCLK2' and 'SDMMCCLK'. Diagram reference: ai15898b.

Figure 402. SDMMC block diagram showing the internal components: APB2 interface and SDMMC adapter, and their external connections.

By default SDMMC_D0 is used for data transfer. After initialization, the host can change the databus width.

If a MultiMediaCard is connected to the bus, SDMMC_D0, SDMMC_D[3:0] or SDMMC_D[7:0] can be used for data transfer. MMC V3.31 or previous, supports only 1 bit of data so only SDMMC_D0 can be used.

If an SD or SD I/O card is connected to the bus, data transfer can be configured by the host to use SDMMC_D0 or SDMMC_D[3:0]. All data lines are operating in push-pull mode.

SDMMC_CMD has two operational modes:

SDMMC_CK is the clock to the card: one bit is transferred on both command and data lines with each clock cycle.

The SDMMC uses two clock signals:

PCLK2 and SDMMC_CK clock frequencies must respect the following condition:

\[ \text{Frequenc(PCLK2)} > ((3 \times \text{Width}) / 32) \times \text{Frequency(SDMMC\_CK)} \]

The signals shown in Table 187 are used on the MultiMediaCard/SD/SD I/O card bus.

Table 187. SDMMC I/O definitions

PinDirectionDescription
SDMMC_CKOutputMultiMediaCard/SD/SDIO card clock. This pin is the clock from host to card.
SDMMC_CMDBidirectionalMultiMediaCard/SD/SDIO card command. This pin is the bidirectional command/response signal.
SDMMC_D[7:0]BidirectionalMultiMediaCard/SD/SDIO card data. These pins are the bidirectional databus.

30.3.1 SDMMC adapter

Figure 403 shows a simplified block diagram of an SDMMC adapter.

Figure 403. SDMMC adapter block diagram. The diagram shows the internal structure of the SDMMC adapter. It includes an 'Adapter registers' block and a 'FIFO' block connected to an 'APB2 interface'. These are connected to a 'Control unit', 'Command path', and 'Data path' block. The 'Control unit' is connected to 'SDMMC_CK', 'SDMMC_CMD', and 'SDMMC_D[7:0]' signals, which are part of the 'Card bus'. The 'Data path' is also connected to 'SDMMC_D[7:0]'. The 'Control unit', 'Command path', and 'Data path' are powered by 'SDMMCCLK'. The 'Adapter registers' and 'FIFO' are powered by 'PCLK2'. The diagram is labeled 'ai15899b'.

Figure 403. SDMMC adapter

Figure 403. SDMMC adapter block diagram. The diagram shows the internal structure of the SDMMC adapter. It includes an 'Adapter registers' block and a 'FIFO' block connected to an 'APB2 interface'. These are connected to a 'Control unit', 'Command path', and 'Data path' block. The 'Control unit' is connected to 'SDMMC_CK', 'SDMMC_CMD', and 'SDMMC_D[7:0]' signals, which are part of the 'Card bus'. The 'Data path' is also connected to 'SDMMC_D[7:0]'. The 'Control unit', 'Command path', and 'Data path' are powered by 'SDMMCCLK'. The 'Adapter registers' and 'FIFO' are powered by 'PCLK2'. The diagram is labeled 'ai15899b'.

The SDMMC adapter is a multimedia/secure digital memory card bus master that provides an interface to a multimedia card stack or to a secure digital memory card. It consists of five subunits:

Note: The adapter registers and FIFO use the APB2 bus clock domain (PCLK2). The control unit, command path and data path use the SDMMC adapter clock domain (SDMMCCLK).

Adapter register block

The adapter register block contains all system registers. This block also generates the signals that clear the static flags in the multimedia card. The clear signals are generated when 1 is written into the corresponding bit location in the SDMMC Clear register.

Control unit

The control unit contains the power management functions and the clock divider for the memory card clock.

There are three power phases:

Figure 404. Control unit

Figure 404. Control unit diagram showing the internal structure of the SDMMC control unit. The control unit contains two subunits: Power management and Clock management. The Power management subunit is connected to the Adapter registers and the Clock management subunit. The Clock management subunit generates the SDMMC_CK signal and is also connected to the command and data path. The Adapter registers are connected to the Power management subunit and the Clock management subunit.
graph TD
    subgraph Control_unit [Control unit]
        PM[Power management]
        CM[Clock management]
        PM --> CM
    end
    AR[Adapter registers] --> PM
    AR --> CM
    CM --> SDMMC_CK[SDMMC_CK]
    CM --> To_command_and_data_path[To command and data path]
    To_command_and_data_path --> CM
    ai14804b
  
Figure 404. Control unit diagram showing the internal structure of the SDMMC control unit. The control unit contains two subunits: Power management and Clock management. The Power management subunit is connected to the Adapter registers and the Clock management subunit. The Clock management subunit generates the SDMMC_CK signal and is also connected to the command and data path. The Adapter registers are connected to the Power management subunit and the Clock management subunit.

The control unit is illustrated in Figure 404 . It consists of a power management subunit and a clock management subunit.

The power management subunit disables the card bus output signals during the power-off and power-up phases.

The clock management subunit generates and controls the SDMMC_CK signal. The SDMMC_CK output can use either the clock divide or the clock bypass mode. The clock output is inactive:

The clock management subunit controls SDMMC_CK dephasing. When not in bypass mode the SDMMC command and data output are generated on the SDMMCCLK falling edge succeeding the rising edge of SDMMC_CK. (SDMMC_CK rising edge occurs on SDMMCCLK rising edge) when SDMMC_CLKCR[13] bit is reset (NEGEDGE = 0). When SDMMC_CLKCR[13] bit is set (NEGEDGE = 1) SDMMC command and data changed on the SDMMC_CK falling edge.

When SDMMC_CLKCR[10] is set (BYPASS = 1), SDMMC_CK rising edge occurs on SDMMCCLK rising edge. The data and the command change on SDMMCCLK falling edge whatever NEGEDGE value.

The data and command responses are latched using SDMMC_CK rising edge.

Timing diagram showing SDMMC_CK clock dephasing. It displays two sets of waveforms for SDMMCCLK and SDMMC_CK. On the left, for NEGEDGE = 0, the SDMMC_CK signal is in phase with SDMMCCLK. On the right, for NEGEDGE = 1, the SDMMC_CK signal is 180 degrees out of phase with SDMMCCLK. Below the waveforms, CMD / Data output signals are shown. The diagram is labeled MSv36077V1.

Figure 405. SDMMC_CK clock dephasing (BYPASS = 0)

Timing diagram showing SDMMC_CK clock dephasing. It displays two sets of waveforms for SDMMCCLK and SDMMC_CK. On the left, for NEGEDGE = 0, the SDMMC_CK signal is in phase with SDMMCCLK. On the right, for NEGEDGE = 1, the SDMMC_CK signal is 180 degrees out of phase with SDMMCCLK. Below the waveforms, CMD / Data output signals are shown. The diagram is labeled MSv36077V1.

Command path

The command path unit sends commands to and receives responses from the cards.

Block diagram of the SDMMC adapter command path. It shows the internal components: Status flag, Control logic, and Command timer (collectively the CPSM) connected to a control unit. Below this, the Command path includes Adapter registers (CMD and Argument), a Shift register, a CRC block, and SDMMC_CMDin and SDMMC_CMDout pins. A stack of registers (CMD, Response, registers) is shown connected to an APB2 interface and the Shift register. The diagram is labeled ai15900b.

Figure 406. SDMMC adapter command path

Block diagram of the SDMMC adapter command path. It shows the internal components: Status flag, Control logic, and Command timer (collectively the CPSM) connected to a control unit. Below this, the Command path includes Adapter registers (CMD and Argument), a Shift register, a CRC block, and SDMMC_CMDin and SDMMC_CMDout pins. A stack of registers (CMD, Response, registers) is shown connected to an APB2 interface and the Shift register. The diagram is labeled ai15900b.

Figure 407. Command path state machine (SDMMC)

Figure 407. Command path state machine (SDMMC). A state machine diagram with five states: Idle, Pend, Send, Wait, and Receive. Transitions are labeled with conditions like 'On reset', 'CPSM enabled and pending command', 'CPSM disabled', 'Enabled and command start', 'CPSM disabled or no response', 'Last data', 'Wait for response', 'CPSM disabled or command timeout', 'Response received or disabled or command CRC failed', and 'Response started'. A small code 'MS34444V1' is in the bottom right corner of the diagram area.
stateDiagram-v2
    [*] --> Idle : On reset
    Idle --> Pend : CPSM enabled and pending command
    Idle --> Send : Enabled and command start
    Idle --> Idle : CPSM disabled
    Pend --> Idle : CPSM disabled
    Pend --> Send : Last data
    Send --> Idle : CPSM disabled or no response
    Send --> Wait : Wait for response
    Wait --> Idle : CPSM disabled or command timeout
    Wait --> Receive : Response started
    Receive --> Idle : Response received or disabled or command CRC failed
  
Figure 407. Command path state machine (SDMMC). A state machine diagram with five states: Idle, Pend, Send, Wait, and Receive. Transitions are labeled with conditions like 'On reset', 'CPSM enabled and pending command', 'CPSM disabled', 'Enabled and command start', 'CPSM disabled or no response', 'Last data', 'Wait for response', 'CPSM disabled or command timeout', 'Response received or disabled or command CRC failed', and 'Response started'. A small code 'MS34444V1' is in the bottom right corner of the diagram area.

When the Wait state is entered, the command timer starts running. If the timeout is reached before the CPSM moves to the Receive state, the timeout flag is set and the Idle state is entered.

Note: The command timeout has a fixed value of 64 SDMMC_CK clock periods.

If the interrupt bit is set in the command register, the timer is disabled and the CPSM waits for an interrupt request from one of the cards. If a pending bit is set in the command register, the CPSM enters the Pend state, and waits for a CmdPend signal from the data path subunit. When CmdPend is detected, the CPSM moves to the Send state. This enables the data counter to trigger the stop command transmission.

Note: The CPSM remains in the Idle state for at least eight SDMMC_CK periods to meet the \( N_{CC} \) and \( N_{RC} \) timing constraints. \( N_{CC} \) is the minimum delay between two host commands, and \( N_{RC} \) is the minimum delay between the host command and the card response.

Figure 408. SDMMC command transfer

Timing diagram for SDMMC command transfer showing SDMMC_CK and SDMMC_CMD signals. The diagram illustrates the sequence of Idle, Command (Send), Wait, Response (Receive), Idle, and Command (Send) states. The SDMMC_CMD signal is in Hi-Z state during Idle and Wait periods, and is driven by the Controller during Command periods and by the Card during the Response period. A minimum of 8 SDMMC_CK cycles is required between the end of one Command and the start of the next.

The diagram shows the timing of SDMMC command transfers. The top signal, SDMMC_CK, is a periodic clock. The bottom signal, SDMMC_CMD, is a command line. The sequence of events is:

A horizontal double-headed arrow indicates that there must be at least 8 SDMMC_CK cycles between the end of one command and the start of the next.

Timing diagram for SDMMC command transfer showing SDMMC_CK and SDMMC_CMD signals. The diagram illustrates the sequence of Idle, Command (Send), Wait, Response (Receive), Idle, and Command (Send) states. The SDMMC_CMD signal is in Hi-Z state during Idle and Wait periods, and is driven by the Controller during Command periods and by the Card during the Response period. A minimum of 8 SDMMC_CK cycles is required between the end of one Command and the start of the next.

The command path operates in a half-duplex mode, so that commands and responses can either be sent or received. If the CPSM is not in the Send state, the SDMMC_CMD output is in the Hi-Z state, as shown in Figure 408 on page 1074 . Data on SDMMC_CMD are synchronous with the rising edge of SDMMC_CK. Table 188 shows the command format.

Table 188. Command format

Bit positionWidthValueDescription
4710Start bit
4611Transmission bit
[45:40]6-Command index
[39:8]32-Argument
[7:1]7-CRC7
011End bit

The SDMMC supports two response types. Both use CRC error checking:

Note: If the response does not contain a CRC (CMD1 response), the device driver must ignore the CRC failed status.

Table 189. Short response format

Bit positionWidthValueDescription
4710Start bit
4610Transmission bit
[45:40]6-Command index
[39:8]32-Argument
[7:1]7-CRC7(or 1111111)
011End bit

Table 190. Long response format

Bit positionWidthValueDescription
13510Start bit
13410Transmission bit
[133:128]6111111Reserved
[127:1]127-CID or CSD (including internal CRC7)
011End bit

The command register contains the command index (six bits sent to a card) and the command type. These determine whether the command requires a response, and whether the response is 48 or 136 bits long (see Section 30.8.4 on page 1111 ). The command path implements the status flags shown in Table 191 :

Table 191. Command path status flags

FlagDescription
CMDRENDSet if response CRC is OK.
CCRCFAILSet if response CRC fails.
CMDSENTSet when command (that does not require response) is sent
CTIMEOUTResponse timeout.
CMDACTCommand transfer in progress.

The CRC generator calculates the CRC checksum for all bits before the CRC code. This includes the start bit, transmitter bit, command index, and command argument (or card status). The CRC checksum is calculated for the first 120 bits of CID or CSD for the long response format. Note that the start bit, transmitter bit and the six reserved bits are not used in the CRC calculation.

The CRC checksum is a 7-bit value:

\[ \text{CRC}[6:0] = \text{Remainder } [(M(x) * x^7) / G(x)] \]

\[ G(x) = x^7 + x^3 + 1 \]

\[ M(x) = (\text{start bit}) * x^{39} + \dots + (\text{last bit before CRC}) * x^0, \text{ or} \]

\[ M(x) = (\text{start bit}) * x^{119} + \dots + (\text{last bit before CRC}) * x^0 \]

Data path

The data path subunit transfers data to and from cards. Figure 409 shows a block diagram of the data path.

Figure 409. Data path

Block diagram of the Data path subunit. The diagram shows a 'Data path' block containing 'Status flag', 'Control logic', and 'Data timer' connected to a 'To control unit'. Below this, a 'Data FIFO' contains 'Transmit' and 'Receive' blocks. The 'Transmit' block connects to a 'Shift register', which then connects to a 'CRC' block. The 'CRC' block outputs to 'SDMMC_Dout[7:0]'. The 'Receive' block also connects to the 'Shift register'. The 'Shift register' also receives input from 'SDMMC_Din[7:0]'. The 'Data path' block also has connections to the 'Shift register' and the 'CRC' block. The diagram is labeled 'ai14808b' in the bottom right corner.
Block diagram of the Data path subunit. The diagram shows a 'Data path' block containing 'Status flag', 'Control logic', and 'Data timer' connected to a 'To control unit'. Below this, a 'Data FIFO' contains 'Transmit' and 'Receive' blocks. The 'Transmit' block connects to a 'Shift register', which then connects to a 'CRC' block. The 'CRC' block outputs to 'SDMMC_Dout[7:0]'. The 'Receive' block also connects to the 'Shift register'. The 'Shift register' also receives input from 'SDMMC_Din[7:0]'. The 'Data path' block also has connections to the 'Shift register' and the 'CRC' block. The diagram is labeled 'ai14808b' in the bottom right corner.

The card databus width can be programmed using the clock control register. If the 4-bit wide bus mode is enabled, data is transferred at four bits per clock cycle over all four data signals (SDMMC_D[3:0]). If the 8-bit wide bus mode is enabled, data is transferred at eight bits per clock cycle over all eight data signals (SDMMC_D[7:0]). If the wide bus mode is not enabled, only one bit per clock cycle is transferred over SDMMC_D0.

Depending on the transfer direction (send or receive), the data path state machine (DPSM) moves to the Wait_S or Wait_R state when it is enabled:

Data path state machine (DPSM)

The DPSM operates at SDMMC_CK frequency. Data on the card bus signals is synchronous to the rising edge of SDMMC_CK. The DPSM has six states, as shown in Figure 410: Data path state machine (DPSM) .

Figure 410. Data path state machine (DPSM)

Figure 410. Data path state machine (DPSM) state transition diagram. The diagram shows six states: Idle, Busy, Wait_S, Send, Wait_R, Receive, and Read Wait. Transitions are triggered by various conditions such as reset, enable signals, data ready, start bit, end of packet, or error conditions like FIFO overrun or CRC fail.
stateDiagram-v2
    [*] --> Idle : On reset
    Idle --> Idle : Disabled or FIFO underrun or
end of data or CRC fail Idle --> Idle : Disabled or CRC fail
or timeout Idle --> Idle : Disabled or
end of data Idle --> Read Wait : DPSM disabled Idle --> Read Wait : DPSM enabled and
Read Wait Started
and SD I/O mode enabled Idle --> Wait_S : Enable and send Idle --> Wait_R : Enable and not send Busy --> Idle : Disabled or CRC fail
or timeout Busy --> Send : End of packet Wait_S --> Idle : Data ready Wait_S --> Send : Not busy Send --> Idle : Data ready Send --> Busy : End of packet Wait_R --> Idle : Disabled or CRC fail Wait_R --> Receive : Start bit Wait_R --> Idle : Disabled or
Rx FIFO empty or timeout or
start bit error Receive --> Wait_R : End of packet or
end of data or
FIFO overrun Receive --> Idle : Disabled or CRC fail Read Wait --> Idle : ReadWait Stop Read Wait --> Wait_R : Data received and
Read Wait Started and
SD I/O mode enabled
Figure 410. Data path state machine (DPSM) state transition diagram. The diagram shows six states: Idle, Busy, Wait_S, Send, Wait_R, Receive, and Read Wait. Transitions are triggered by various conditions such as reset, enable signals, data ready, start bit, end of packet, or error conditions like FIFO overrun or CRC fail.

Note: The DPSM remains in the Wait_S state for at least two clock periods to meet the \( N_{WR} \) timing requirements, where \( N_{WR} \) is the number of clock cycles between the reception of the card response and the start of the data transfer from the host.

If a FIFO underrun error occurs, the DPSM sets the FIFO error flag and moves to the Idle state.

If a timeout occurs while the DPSM is in the Busy state, it sets the data timeout flag and moves to the Idle state.

The data timer is enabled when the DPSM is in the Wait_R or Busy state, and generates the data timeout error:

Table 192. Data token format

DescriptionStart bitDataCRC16End bit
Block Data0-yes1
Stream Data0-no1

DPSM Flags

The status of the data path subunit transfer is reported by several status flags

Table 193. DPSM flags

FlagDescription
DBCKENDSet to high when data block send/receive CRC check is passed.
In SDIO multibyte transfer mode this flag is set at the end of the transfer (a multibyte transfer is considered as a single block transfer by the host).
DATAENDSet to high when SDMMC_DCOUNT register decrements and reaches 0.
DATAEND indicates the end of a transfer on SDMMC data line.
DTIMEOUTSet to high when data timeout period is reached.
When data timer reaches zero while DPSM is in Wait_R or Busy state, timeout is set. DTIMEOUT can be set after DATAEND if DPSM remains in busy state for longer than the programmed period.
DCRCFAILSet to high when data block send/receive CRC check fails.

Data FIFO

The data FIFO (first-in-first-out) subunit is a data buffer with a transmit and receive unit.

The FIFO contains a 32-bit wide, 32-word deep data buffer, and transmit and receive logic. Because the data FIFO operates in the APB2 clock domain (PCLK2), all signals from the subunits in the SDMMC clock domain (SDMMCCLK) are resynchronized.

Depending on the TXACT and RXACT flags, the FIFO can be disabled, transmit enabled, or receive enabled. TXACT and RXACT are driven by the data path subunit and are mutually exclusive:

Data can be written to the transmit FIFO through the APB2 interface when the SDMMC is enabled for transmission.

The transmit FIFO is accessible via 32 sequential addresses. The transmit FIFO contains a data output register that holds the data word pointed to by the read pointer. When the data path subunit has loaded its shift register, it increments the read pointer and drives new data out.

If the transmit FIFO is disabled, all status flags are deasserted. The data path subunit asserts TXACT when it transmits data.

Table 194. Transmit FIFO status flags
FlagDescription
TXFIFOESet to high when the transmit FIFO does not contain valid data.
TXFIFOHSet to high when 8 or more transmit FIFO words are empty. This flag can be used as a DMA request.
TXDAVLSet to high when the transmit FIFO contains valid data. This flag is the inverse of the TXFIFOE flag.
TXUNDERRSet to high when an underrun error occurs. This flag is cleared by writing to the SDMMC Clear register.
Note: In case of TXUNDERR, and DMA is used to fill SDMMC FIFO, user software should disable DMA stream, and then write DMAEN bit in SDMMC_DCTRL with '0' (to disable DMA request generation).

When the data path subunit receives a word of data, it drives the data on the write databus. The write pointer is incremented after the write operation completes. On the read side, the contents of the FIFO word pointed to by the current value of the read pointer is driven onto the read databus. If the receive FIFO is disabled, all status flags are deasserted, and the read and write pointers are reset. The data path subunit asserts RXACT when it receives data. Table 195 lists the receive FIFO status flags. The receive FIFO is accessible via 32 sequential addresses.

Table 195. Receive FIFO status flags
FlagDescription
RXFIFOESet to high when the receive FIFO does not contain valid data.
RXFIFOHSet to high when 8 or more receive FIFO words contain valid data. This flag can be used as a DMA request.
RXDAVLSet to high when the receive FIFO is not empty. This flag is the inverse of the RXFIFOE flag.
RXOVERRSet to high when an overrun error occurs. This flag is cleared by writing to the SDMMC Clear register.
Note: In case of RXOVERR, and DMA is used to read SDMMC FIFO, user software should disable DMA stream, and then write DMAEN bit in SDMMC_DCTRL with '0' (to disable DMA request generation).

30.3.2 SDMMC APB2 interface

The APB2 interface generates the interrupt and DMA requests, and accesses the SDMMC adapter registers and the data FIFO. It consists of a data path, register decoder, and interrupt/DMA logic.

SDMMC interrupts

The interrupt logic generates an interrupt request signal that is asserted when at least one of the selected status flags is high. A mask register is provided to allow selection of the conditions that will generate an interrupt. A status flag generates the interrupt request if a corresponding mask flag is set.

SDMMC/DMA interface

SDMMC APB interface controls all subunit to perform transfers between the host and card

Example of read procedure using DMA

Send CMD17 (READ_BLOCK) as follows:

  1. a) Program the SDMMC data length register (SDMMC data timer register should be already programmed before the card identification process)
  2. b) Program DMA channel (refer to DMA configuration for SDMMC controller )
  3. c) Program the SDMMC data control register: DTEN with '1' (SDMMC card host enabled to send data); DTDIR with '1' (from card to controller); DTMODE with '0' (block data transfer); DMAEN with '1' (DMA enabled); DBLOCKSIZE with 0x9 (512 bytes). Other fields are don't care.
  4. d) Program the SDMMC argument register with the address location of the card from where data is to be transferred
  5. e) Program the SDMMC command register: CmdIndex with 17(READ_BLOCK); WaitResp with '1' (SDMMC card host waits for a response); CPSMEN with '1' (SDMMC card host enabled to send a command). Other fields are at their reset value.
  6. f) Wait for SDMMC_STA[6] = CMDREND interrupt, (CMDREND is set if there is no error on command path).
  7. g) Wait for SDMMC_STA[10] = DBCKEND, (DBCKEND is set in case of no errors until the CRC check is passed)
  8. h) Wait until the FIFO is empty, when FIFO is empty the SDMMC_STA[5] = RXOVERR value has to be checked to guarantee that read succeeded

Note: When FIFO overrun error occurs with last 1-4 bytes, it may happen that RXOVERR flag is set 2 APB clock cycles after DATAEND flag is set. To guarantee success of read operation RXOVERR must be checked after FIFO is empty.

Example of write procedure using DMA

Send CMD24 (WRITE_BLOCK) as follows:

  1. Program the SDMMC data length register (SDMMC data timer register should be already programmed before the card identification process)
  2. Program DMA channel (refer to DMA configuration for SDMMC controller )
  3. Program the SDMMC argument register with the address location of the card from where data is to be transferred
  4. Program the SDMMC command register: CmdIndex with 24(WRITE_BLOCK); WaitResp with '1' (SDMMC card host waits for a response); CPSMEN with '1' (SDMMC card host enabled to send a command). Other fields are at their reset value.
  5. Wait for SDMMC_STA[6] = CMDREND interrupt, then Program the SDMMC data control register: DTEN with '1' (SDMMC card host enabled to send data); DTDIR with '0' (from controller to card); DTMODE with '0' (block data transfer); DMAEN with '1' (DMA enabled); DBLOCKSIZE with 0x9 (512 bytes). Other fields are don't care.
  6. Wait for SDMMC_STA[10] = DBCKEND, (DBCKEND is set in case of no errors)

DMA configuration for SDMMC controller

  1. Enable DMA2 controller and clear any pending interrupts.
  2. Program the DMA2_Stream3 (or DMA2_Stream6) Channel4 source address register with the memory location base address and DMA2_Stream3 (or DMA2_Stream6) Channel4 destination address register with the SDMMC_FIFO register address.
  3. Program DMA2_Stream3 (or DMA2_Stream6) Channel4 control register (memory increment, not peripheral increment, peripheral and source width is word size).
  4. Program DMA2_Stream3 (or DMA2_Stream6) Channel4 to select the peripheral as flow controller (set PFCTRL bit in DMA_S3CR (or DMA_S6CR) configuration register).
  5. Configure the incremental burst transfer to 4 beats (at least from peripheral side) in DMA2_Stream3 (or DMA2_Stream6) Channel4.
  6. Enable DMA2_Stream3 (or DMA2_Stream6) Channel4

Note: SDMMC host allows only to use the DMA in peripheral flow controller mode. DMA stream used to serve SDMMC must be configured in peripheral flow controller mode

SDMMC generates only DMA burst requests to DMA controller. DMA must be configured in incremental burst mode on peripheral side.

30.4 Card functional description

30.4.1 Card identification mode

While in card identification mode the host resets all cards, validates the operation voltage range, identifies cards and sets a relative card address (RCA) for each card on the bus. All data communications in the card identification mode use the command line (CMD) only.

30.4.2 Card reset

The GO_IDLE_STATE command (CMD0) is the software reset command and it puts the MultiMediaCard and SD memory in the Idle state. The IO_RW_DIRECT command (CMD52) resets the SD I/O card. After power-up or CMD0, all cards output bus drivers are in the high-impedance state and the cards are initialized with a default relative card address (RCA=0x0001) and with a default driver stage register setting (lowest speed, highest driving current capability).

30.4.3 Operating voltage range validation

All cards can communicate with the SDMMC card host using any operating voltage within the specification range. The supported minimum and maximum \( V_{DD} \) values are defined in the operation conditions register (OCR) on the card.

Cards that store the card identification number (CID) and card specific data (CSD) in the payload memory are able to communicate this information only under data-transfer \( V_{DD} \) conditions. When the SDMMC card host module and the card have incompatible \( V_{DD} \) ranges, the card is not able to complete the identification cycle and cannot send CSD data. For this purpose, the special commands, SEND_OP_COND (CMD1), SD_APP_OP_COND (ACMD41 for SD Memory), and IO_SEND_OP_COND (CMD5 for SD I/O), are designed to provide a mechanism to identify and reject cards that do not match the \( V_{DD} \) range desired by the SDMMC card host. The SDMMC card host sends the required \( V_{DD} \) voltage window as the operand of these commands. Cards that cannot perform data transfer in the specified range disconnect from the bus and go to the inactive state.

By using these commands without including the voltage range as the operand, the SDMMC card host can query each card and determine the common voltage range before placing out-of-range cards in the inactive state. This query is used when the SDMMC card host is able to select a common voltage range or when the user requires notification that cards are not usable.

30.4.4 Card identification process

The card identification process differs for MultiMediaCards and SD cards. For MultiMediaCard cards, the identification process starts at clock rate \( F_{od} \) . The SDMMC_CMD line output drivers are open-drain and allow parallel card operation during this process. The registration process is accomplished as follows:

  1. 1. The bus is activated.
  2. 2. The SDMMC card host broadcasts SEND_OP_COND (CMD1) to receive operation conditions.
  3. 3. The response is the wired AND operation of the operation condition registers from all cards.
  4. 4. Incompatible cards are placed in the inactive state.
  5. 5. The SDMMC card host broadcasts ALL_SEND_CID (CMD2) to all active cards.
  6. 6. The active cards simultaneously send their CID numbers serially. Cards with outgoing CID bits that do not match the bits on the command line stop transmitting and must wait for the next identification cycle. One card successfully transmits a full CID to the SDMMC card host and enters the Identification state.
  7. 7. The SDMMC card host issues SET_RELATIVE_ADDR (CMD3) to that card. This new address is called the relative card address (RCA); it is shorter than the CID and

addresses the card. The assigned card changes to the Standby state, it does not react to further identification cycles, and its output switches from open-drain to push-pull.

  1. 8. The SDMMC card host repeats steps 5 through 7 until it receives a timeout condition.

For the SD card, the identification process starts at clock rate \( F_{od} \) , and the SDMMC_CMD line output drives are push-pull drivers instead of open-drain. The registration process is accomplished as follows:

  1. 1. The bus is activated.
  2. 2. The SDMMC card host broadcasts SD_APP_OP_COND (ACMD41).
  3. 3. The cards respond with the contents of their operation condition registers.
  4. 4. The incompatible cards are placed in the inactive state.
  5. 5. The SDMMC card host broadcasts ALL_SEND_CID (CMD2) to all active cards.
  6. 6. The cards send back their unique card identification numbers (CIDs) and enter the Identification state.
  7. 7. The SDMMC card host issues SET_RELATIVE_ADDR (CMD3) to an active card with an address. This new address is called the relative card address (RCA); it is shorter than the CID and addresses the card. The assigned card changes to the Standby state. The SDMMC card host can reissue this command to change the RCA. The RCA of the card is the last assigned value.
  8. 8. The SDMMC card host repeats steps 5 through 7 with all active cards.

For the SD I/O card, the registration process is accomplished as follows:

  1. 1. The bus is activated.
  2. 2. The SDMMC card host sends IO_SEND_OP_COND (CMD5).
  3. 3. The cards respond with the contents of their operation condition registers.
  4. 4. The incompatible cards are set to the inactive state.
  5. 5. The SDMMC card host issues SET_RELATIVE_ADDR (CMD3) to an active card with an address. This new address is called the relative card address (RCA); it is shorter than the CID and addresses the card. The assigned card changes to the Standby state. The SDMMC card host can reissue this command to change the RCA. The RCA of the card is the last assigned value.

30.4.5 Block write

During block write (CMD24 - 27) one or more blocks of data are transferred from the host to the card with a CRC appended to the end of each block by the host. A card supporting block write is always able to accept a block of data defined by WRITE_BL_LEN. If the CRC fails, the card indicates the failure on the SDMMC_D line and the transferred data are discarded and not written, and all further transmitted blocks (in multiple block write mode) are ignored.

If the host uses partial blocks whose accumulated length is not block aligned and, block misalignment is not allowed (CSD parameter WRITE_BLK_MISALIGN is not set), the card will detect the block misalignment error before the beginning of the first misaligned block. (ADDRESS_ERROR error bit is set in the status register). The write operation will also be aborted if the host tries to write over a write-protected area. In this case, however, the card will set the WP_VIOLATION bit.

Programming of the CID and CSD registers does not require a previous block length setting. The transferred data is also CRC protected. If a part of the CSD or CID register is stored in ROM, then this unchangeable part must match the corresponding part of the receive buffer. If this match fails, then the card reports an error and does not change any register contents.

Some cards may require long and unpredictable times to write a block of data. After receiving a block of data and completing the CRC check, the card begins writing and holds the SDMMC_D line low if its write buffer is full and unable to accept new data from a new WRITE_BLOCK command. The host may poll the status of the card with a SEND_STATUS command (CMD13) at any time, and the card will respond with its status. The READY_FOR_DATA status bit indicates whether the card can accept new data or whether the write process is still in progress. The host may deselect the card by issuing CMD7 (to select a different card), which will place the card in the Disconnect state and release the SDMMC_D line(s) without interrupting the write operation. When reselecting the card, it will reactivate busy indication by pulling SDMMC_D to low if programming is still in progress and the write buffer is unavailable.

30.4.6 Block read

In Block read mode the basic unit of data transfer is a block whose maximum size is defined in the CSD (READ_BL_LEN). If READ_BL_PARTIAL is set, smaller blocks whose start and end addresses are entirely contained within one physical block (as defined by READ_BL_LEN) may also be transmitted. A CRC is appended to the end of each block, ensuring data transfer integrity. CMD17 (READ_SINGLE_BLOCK) initiates a block read and after completing the transfer, the card returns to the Transfer state.

CMD18 (READ_MULTIPLE_BLOCK) starts a transfer of several consecutive blocks.

The host can abort reading at any time, within a multiple block operation, regardless of its type. Transaction abort is done by sending the stop transmission command.

If the card detects an error (for example, out of range, address misalignment or internal error) during a multiple block read operation (both types) it stops the data transmission and remains in the data state. The host must then abort the operation by sending the stop transmission command. The read error is reported in the response to the stop transmission command.

If the host sends a stop transmission command after the card transmits the last block of a multiple block operation with a predefined number of blocks, it is responded to as an illegal command, since the card is no longer in the data state. If the host uses partial blocks whose accumulated length is not block-aligned and block misalignment is not allowed, the card detects a block misalignment error condition at the beginning of the first misaligned block (ADDRESS_ERROR error bit is set in the status register).

30.4.7 Stream access, stream write and stream read (MultiMediaCard only)

In stream mode, data is transferred in bytes and no CRC is appended at the end of each block.

Stream write (MultiMediaCard only)

WRITE_DAT_UNTIL_STOP (CMD20) starts the data transfer from the SDMMC card host to the card, beginning at the specified address and continuing until the SDMMC card host issues a stop command. When partial blocks are allowed (CSD parameter WRITE_BL_PARTIAL is set), the data stream can start and stop at any address within the card address space, otherwise it can only start and stop at block boundaries. Because the amount of data to be transferred is not determined in advance, a CRC cannot be used. When the end of the memory range is reached while sending data and no stop command is sent by the SDMMC card host, any additional transferred data are discarded.

The maximum clock frequency for a stream write operation is given by the following equation fields of the card-specific data register:

\[ \text{Maximumspeed} = \text{MIN}(\text{TRANSPEED}, \frac{(8 \times 2^{\text{writeblalen}})(-\text{NSAC}}{\text{TAAC} \times \text{R2WFACTOR}}) \]

If the host attempts to use a higher frequency, the card may not be able to process the data and stop programming, set the OVERRUN error bit in the status register, and while ignoring all further data transfer, wait (in the receive data state) for a stop command. The write operation is also aborted if the host tries to write over a write-protected area. In this case, however, the card sets the WP_VIOLATION bit.

Stream read (MultiMediaCard only)

READ_DAT_UNTIL_STOP (CMD11) controls a stream-oriented data transfer.

This command instructs the card to send its data, starting at a specified address, until the SDMMC card host sends STOP_TRANSMISSION (CMD12). The stop command has an execution delay due to the serial command transmission and the data transfer stops after the end bit of the stop command. When the end of the memory range is reached while sending data and no stop command is sent by the SDMMC card host, any subsequent data sent are considered undefined.

The maximum clock frequency for a stream read operation is given by the following equation and uses fields of the card specific data register.

\[ \text{Maximumspeed} = \text{MIN}(\text{TRANSPEED}, \frac{(8 \times 2^{\text{readblalen}})(-\text{NSAC}}{\text{TAAC} \times \text{R2WFACTOR}}) \]

If the host attempts to use a higher frequency, the card is not able to sustain data transfer. If this happens, the card sets the UNDERRUN error bit in the status register, aborts the transmission and waits in the data state for a stop command.

30.4.8 Erase: group erase and sector erase

The erasable unit of the MultiMediaCard is the erase group. The erase group is measured in write blocks, which are the basic writable units of the card. The size of the erase group is a card-specific parameter and defined in the CSD.

The host can erase a contiguous range of Erase Groups. Starting the erase process is a three-step sequence.

First the host defines the start address of the range using the ERASE_GROUP_START (CMD35) command, next it defines the last address of the range using the ERASE_GROUP_END (CMD36) command and, finally, it starts the erase process by issuing the ERASE (CMD38) command. The address field in the erase commands is an Erase Group address in byte units. The card ignores all LSBs below the Erase Group size, effectively rounding the address down to the Erase Group boundary.

If an erase command is received out of sequence, the card sets the ERASE_SEQ_ERROR bit in the status register and resets the whole sequence.

If an out-of-sequence (neither of the erase commands, except SEND_STATUS) command received, the card sets the ERASE_RESET status bit in the status register, resets the erase sequence and executes the last command.

If the erase range includes write protected blocks, they are left intact and only nonprotected blocks are erased. The WP_ERASE_SKIP status bit in the status register is set.

The card indicates that an erase is in progress by holding SDMMC_D low. The actual erase time may be quite long, and the host may issue CMD7 to deselect the card.

30.4.9 Wide bus selection or deselection

Wide bus (4-bit bus width) operation mode is selected or deselected using SET_BUS_WIDTH (ACMD6). The default bus width after power-up or GO_IDLE_STATE (CMD0) is 1 bit. SET_BUS_WIDTH (ACMD6) is only valid in a transfer state, which means that the bus width can be changed only after a card is selected by SELECT/DESELECT_CARD (CMD7).

30.4.10 Protection management

Three write protection methods for the cards are supported in the SDMMC card host module:

  1. 1. internal card write protection (card responsibility)
  2. 2. mechanical write protection switch (SDMMC card host module responsibility only)
  3. 3. password-protected card lock operation

Internal card write protection

Card data can be protected against write and erase. By setting the permanent or temporary write-protect bits in the CSD, the entire card can be permanently write-protected by the manufacturer or content provider. For cards that support write protection of groups of sectors by setting the WP_GRP_ENABLE bit in the CSD, portions of the data can be protected, and the write protection can be changed by the application. The write protection is in units of WP_GRP_SIZE sectors as specified in the CSD. The SET_WRITE_PROT and CLR_WRITE_PROT commands control the protection of the addressed group. The SEND_WRITE_PROT command is similar to a single block read command. The card sends

a data block containing 32 write protection bits (representing 32 write protect groups starting at the specified address) followed by 16 CRC bits. The address field in the write protect commands is a group address in byte units.

The card ignores all LSBs below the group size.

Mechanical write protect switch

A mechanical sliding tab on the side of the card allows the user to set or clear the write protection on a card. When the sliding tab is positioned with the window open, the card is write-protected, and when the window is closed, the card contents can be changed. A matched switch on the socket side indicates to the SDMMC card host module that the card is write-protected. The SDMMC card host module is responsible for protecting the card. The position of the write protect switch is unknown to the internal circuitry of the card.

Password protect

The password protection feature enables the SDMMC card host module to lock and unlock a card with a password. The password is stored in the 128-bit PWD register and its size is set in the 8-bit PWD_LEN register. These registers are nonvolatile so that a power cycle does not erase them. Locked cards respond to and execute certain commands. This means that the SDMMC card host module is allowed to reset, initialize, select, and query for status, however it is not allowed to access data on the card. When the password is set (as indicated by a nonzero value of PWD_LEN), the card is locked automatically after power-up. As with the CSD and CID register write commands, the lock/unlock commands are available in the transfer state only. In this state, the command does not include an address argument and the card must be selected before using it. The card lock/unlock commands have the structure and bus transaction types of a regular single-block write command. The transferred data block includes all of the required information for the command (the password setting mode, the PWD itself, and card lock/unlock). The command data block size is defined by the SDMMC card host module before it sends the card lock/unlock command, and has the structure shown in Table 209 .

The bit settings are as follows:

The following sections list the command sequences to set/reset a password, lock/unlock the card, and force an erase.

Setting the password

  1. 1. Select a card (SELECT/DESELECT_CARD, CMD7), if none is already selected.
  2. 2. Define the block length (SET_BLOCKLEN, CMD16) to send, given by the 8-bit card lock/unlock mode, the 8-bit PWD_LEN, and the number of bytes of the new password.

When a password replacement is done, the block size must take into account that both the old and the new passwords are sent with the command.

  1. 3. Send LOCK/UNLOCK (CMD42) with the appropriate data block size on the data line including the 16-bit CRC. The data block indicates the mode (SET_PWD = 1), the length (PWD_LEN), and the password (PWD) itself. When a password replacement is done, the length value (PWD_LEN) includes the length of both passwords, the old and the new one, and the PWD field includes the old password (currently used) followed by the new password.
  2. 4. When the password is matched, the new password and its size are saved into the PWD and PWD_LEN fields, respectively. When the old password sent does not correspond (in size and/or content) to the expected password, the LOCK_UNLOCK_FAILED error bit is set in the card status register, and the password is not changed.

The password length field (PWD_LEN) indicates whether a password is currently set. When this field is nonzero, there is a password set and the card locks itself after power-up. It is possible to lock the card immediately in the current power session by setting the LOCK_UNLOCK bit (while setting the password) or sending an additional command for card locking.

Resetting the password

  1. 1. Select a card (SELECT/DESELECT_CARD, CMD7), if none is already selected.
  2. 2. Define the block length (SET_BLOCKLEN, CMD16) to send, given by the 8-bit card lock/unlock mode, the 8-bit PWD_LEN, and the number of bytes in the currently used password.
  3. 3. Send LOCK/UNLOCK (CMD42) with the appropriate data block size on the data line including the 16-bit CRC. The data block indicates the mode (CLR_PWD = 1), the length (PWD_LEN) and the password (PWD) itself. The LOCK_UNLOCK bit is ignored.
  4. 4. When the password is matched, the PWD field is cleared and PWD_LEN is set to 0. When the password sent does not correspond (in size and/or content) to the expected password, the LOCK_UNLOCK_FAILED error bit is set in the card status register, and the password is not changed.

Locking a card

  1. 1. Select a card (SELECT/DESELECT_CARD, CMD7), if none is already selected.
  2. 2. Define the block length (SET_BLOCKLEN, CMD16) to send, given by the 8-bit card lock/unlock mode (byte 0 in Table 209 ), the 8-bit PWD_LEN, and the number of bytes of the current password.
  3. 3. Send LOCK/UNLOCK (CMD42) with the appropriate data block size on the data line including the 16-bit CRC. The data block indicates the mode (LOCK_UNLOCK = 1), the length (PWD_LEN), and the password (PWD) itself.
  4. 4. When the password is matched, the card is locked and the CARD_IS_LOCKED status bit is set in the card status register. When the password sent does not correspond (in size and/or content) to the expected password, the LOCK_UNLOCK_FAILED error bit is set in the card status register, and the lock fails.

It is possible to set the password and to lock the card in the same sequence. In this case, the SDMMC card host module performs all the required steps for setting the password (see Setting the password on page 1088 ), however it is necessary to set the LOCK_UNLOCK bit in Step 3 when the new password command is sent.

When the password is previously set (PWD_LEN is not 0), the card is locked automatically after power on reset. An attempt to lock a locked card or to lock a card that does not have a password fails and the LOCK_UNLOCK_FAILED error bit is set in the card status register.

Unlocking the card

  1. 1. Select a card (SELECT/DESELECT_CARD, CMD7), if none is already selected.
  2. 2. Define the block length (SET_BLOCKLEN, CMD16) to send, given by the 8-bit cardlock/unlock mode (byte 0 in Table 209 ), the 8-bit PWD_LEN, and the number of bytes of the current password.
  3. 3. Send LOCK/UNLOCK (CMD42) with the appropriate data block size on the data line including the 16-bit CRC. The data block indicates the mode (LOCK_UNLOCK = 0), the length (PWD_LEN), and the password (PWD) itself.
  4. 4. When the password is matched, the card is unlocked and the CARD_IS_LOCKED status bit is cleared in the card status register. When the password sent is not correct in size and/or content and does not correspond to the expected password, the LOCK_UNLOCK_FAILED error bit is set in the card status register, and the card remains locked.

The unlocking function is only valid for the current power session. When the PWD field is not clear, the card is locked automatically on the next power-up.

An attempt to unlock an unlocked card fails and the LOCK_UNLOCK_FAILED error bit is set in the card status register.

Forcing erase

If the user has forgotten the password (PWD content), it is possible to access the card after clearing all the data on the card. This forced erase operation erases all card data and all password data.

  1. 1. Select a card (SELECT/DESELECT_CARD, CMD7), if none is already selected.
  2. 2. Set the block length (SET_BLOCKLEN, CMD16) to 1 byte. Only the 8-bit card lock/unlock byte (byte 0 in Table 209 ) is sent.
  3. 3. Send LOCK/UNLOCK (CMD42) with the appropriate data byte on the data line including the 16-bit CRC. The data block indicates the mode (ERASE = 1). All other bits must be zero.
  4. 4. When the ERASE bit is the only bit set in the data field, all card contents are erased, including the PWD and PWD_LEN fields, and the card is no longer locked. When any other bits are set, the LOCK_UNLOCK_FAILED error bit is set in the card status register and the card retains all of its data, and remains locked.

An attempt to use a force erase on an unlocked card fails and the LOCK_UNLOCK_FAILED error bit is set in the card status register.

30.4.11 Card status register

The response format R1 contains a 32-bit field named card status. This field is intended to transmit the card status information (which may be stored in a local status register) to the host. If not specified otherwise, the status entries are always related to the previously issued command.

Table 196 defines the different entries of the status. The type and clear condition fields in the table are abbreviated as follows:

Type:

Clear condition:

Table 196. Card status

BitsIdentifierTypeValueDescriptionClear condition
31ADDRESS_OUT_OF_RANGEE R X'0'= no error
'1'= error
The command address argument was out of the allowed range for this card.
A multiple block or stream read/write operation is (although started in a valid address) attempting to read or write beyond the card capacity.
C
30ADDRESS_MISALIGN-'0'= no error
'1'= error
The commands address argument (in accordance with the currently set block length) positions the first data block misaligned to the card physical blocks.
A multiple block read/write operation (although started with a valid address/block-length combination) is attempting to read or write a data block which is not aligned with the physical blocks of the card.
C
29BLOCK_LEN_ERROR-'0'= no error
'1'= error
Either the argument of a SET_BLOCKLEN command exceeds the maximum value allowed for the card, or the previously defined block length is illegal for the current command (e.g. the host issues a write command, the current block length is smaller than the maximum allowed value for the card and it is not allowed to write partial blocks)C

Table 196. Card status (continued)

BitsIdentifierTypeValueDescriptionClear condition
28ERASE_SEQ_ERROR-'0'= no error
'1'= error
An error in the sequence of erase commands occurred.C
27ERASE_PARAME X'0'= no error
'1'= error
An invalid selection of erase groups for erase occurred.C
26WP_VIOLATIONE X'0'= no error
'1'= error
Attempt to program a write-protected block.C
25CARD_IS_LOCKEDS R'0'= card unlocked
'1'= card locked
When set, signals that the card is locked by the hostA
24LOCK_UNLOCK_FAILEDE X'0'= no error
'1'= error
Set when a sequence or password error has been detected in lock/unlock card commandC
23COM_CRC_ERRORE R'0'= no error
'1'= error
The CRC check of the previous command failed.B
22ILLEGAL_COMMANDE R'0'= no error
'1'= error
Command not legal for the card stateB
21CARD_ECC_FAILEDE X'0'= success
'1'= failure
Card internal ECC was applied but failed to correct the data.C
20CC_ERRORE R'0'= no error
'1'= error
(Undefined by the standard) A card error occurred, which is not related to the host command.C
19ERRORE X'0'= no error
'1'= error
(Undefined by the standard) A generic card error related to the (and detected during) execution of the last host command (e.g. read or write failures).C
18Reserved
17Reserved
16CID/CSD_OVERWRITEE X'0'= no error
'1'= error
Can be either of the following errors:
– The CID register has already been written and cannot be overwritten
– The read-only section of the CSD does not match the card contents
– An attempt to reverse the copy (set as original) or permanent WP (unprotected) bits was made
C
15WP_ERASE_SKIPE X'0'= not protected
'1'= protected
Set when only partial address space was erased due to existing writeC
14CARD_ECC_DISABLEDS X'0'= enabled
'1'= disabled
The command has been executed without using the internal ECC.A

Table 196. Card status (continued)

BitsIdentifierTypeValueDescriptionClear condition
13ERASE_RESET-'0'= cleared
'1'= set
An erase sequence was cleared before executing because an out of erase sequence command was received (commands other than CMD35, CMD36, CMD38 or CMD13)C
12:9CURRENT_STATES R0 = Idle
1 = Ready
2 = Ident
3 = Stby
4 = Tran
5 = Data
6 = Rcv
7 = Prg
8 = Dis
9 = Btst
10-15 = reserved
The state of the card when receiving the command. If the command execution causes a state change, it will be visible to the host in the response on the next command. The four bits are interpreted as a binary number between 0 and 15.B
8READY_FOR_DATAS R'0'= not ready
'1'= ready
Corresponds to buffer empty signalling on the bus-
7SWITCH_ERRORE X'0'= no error
'1'= switch error
If set, the card did not switch to the expected mode as requested by the SWITCH commandB
6Reserved
5APP_CMDS R'0' = Disabled
'1' = Enabled
The card will expect ACMD, or an indication that the command has been interpreted as ACMDC
4Reserved for SD I/O Card
3AKE_SEQ_ERRORE R'0'= no error
'1'= error
Error in the sequence of the authentication processC
2Reserved for application specific commands
1Reserved for manufacturer test mode
0

30.4.12 SD status register

The SD status contains status bits that are related to the SD memory card proprietary features and may be used for future application-specific usage. The size of the SD Status is one data block of 512 bits. The contents of this register are transmitted to the SDMMC card host if ACMD13 is sent (CMD55 followed with CMD13). ACMD13 can be sent to a card in transfer state only (card is selected).

Table 197 defines the different entries of the SD status register. The type and clear condition fields in the table are abbreviated as follows:

Type:

Clear condition:

Table 197. SD status

BitsIdentifierTypeValueDescriptionClear condition
511: 510DAT_BUS_WIDTHS R'00'= 1 (default)
'01'= reserved
'10'= 4 bit width
'11'= reserved
Shows the currently defined databus width that was defined by SET_BUS_WIDTH commandA
509SECURED_MODES R'0'= Not in the mode
'1'= In Secured Mode
Card is in Secured Mode of operation (refer to the “SD Security Specification”).A
508: 496Reserved
495: 480SD_CARD_TYPES R'00xxh'= SD Memory Cards as defined in Physical Spec Ver1.01-2.00 ('x'= don't care). The following cards are currently defined:
'0000'= Regular SD RD/WR Card.
'0001'= SD ROM Card
In the future, the 8 LSBs will be used to define different variations of an SD memory card (each bit will define different SD types). The 8 MSBs will be used to define SD Cards that do not comply with current SD physical layer specification.A
479: 448SIZE_OF_PROTECTED_AREAS RSize of protected area (See below)(See below)A
447: 440SPEED_CLASSS RSpeed Class of the card (See below)(See below)A

Table 197. SD status (continued)

BitsIdentifierTypeValueDescriptionClear condition
439: 432PERFORMANCE_MOVES RPerformance of move indicated by 1 [MB/s] step.
(See below)
(See below)A
431:428AU_SIZES RSize of AU
(See below)
(See below)A
427:424Reserved
423:408ERASE_SIZES RNumber of AUs to be erased at a time(See below)A
407:402ERASE_TIMEOUTS RTimeout value for erasing areas specified by UNIT_OF_ERASE_AU(See below)A
401:400ERASE_OFFSETS RFixed offset value added to erase time.(See below)A
399:312Reserved
311:0Reserved for Manufacturer

SIZE_OF_PROTECTED_AREA

Setting this field differs between standard- and high-capacity cards. In the case of a standard-capacity card, the capacity of protected area is calculated as follows:

\[ \text{Protected area} = \text{SIZE\_OF\_PROTECTED\_AREA\_} * \text{MULT} * \text{BLOCK\_LEN}. \]

SIZE_OF_PROTECTED_AREA is specified by the unit in MULT*BLOCK_LEN.

In the case of a high-capacity card, the capacity of protected area is specified in this field:

\[ \text{Protected area} = \text{SIZE\_OF\_PROTECTED\_AREA} \]

SIZE_OF_PROTECTED_AREA is specified by the unit in bytes.

SPEED_CLASS

This 8-bit field indicates the speed class and the value can be calculated by \( P_W/2 \) (where \( P_W \) is the write performance).

Table 198. Speed class code field

SPEED_CLASSValue definition
00hClass 0
01hClass 2
02hClass 4
03hClass 6
04h – FFhReserved

PERFORMANCE_MOVE

This 8-bit field indicates Pm (performance move) and the value can be set by 1 [MB/sec] steps. If the card does not move used RUs (recording units), Pm should be considered as infinity. Setting the field to FFh means infinity.

Table 199. Performance move field

PERFORMANCE_MOVEValue definition
00hNot defined
01h1 [MB/sec]
02h02h 2 [MB/sec]
----------
FEh254 [MB/sec]
FFhInfinity

AU_SIZE

This 4-bit field indicates the AU size and the value can be selected in the power of 2 base from 16 KB.

Table 200. AU_SIZE field

AU_SIZEValue definition
00hNot defined
01h16 KB
02h32 KB
03h64 KB
04h128 KB
05h256 KB
06h512 KB
07h1 MB
08h2 MB
09h4 MB
Ah – FhReserved

The maximum AU size, which depends on the card capacity, is defined in Table 201 . The card can be set to any AU size between RU size and maximum AU size.

Table 201. Maximum AU size

Capacity16 MB-64 MB128 MB-256 MB512 MB1 GB-32 GB
Maximum AU Size512 KB1 MB2 MB4 MB

ERASE_SIZE

This 16-bit field indicates NERASE . When NERASE numbers of AUs are erased, the timeout value is specified by ERASE_TIMEOUT (Refer to ERASE_TIMEOUT ). The host should determine the proper number of AUs to be erased in one operation so that the host can show the progress of the erase operation. If this field is set to 0, the erase timeout calculation is not supported.

Table 202. Erase size field

ERASE_SIZEValue definition
0000hErase timeout calculation is not supported.
0001h1 AU
0002h2 AU
0003h3 AU
----------
FFFFh65535 AU

ERASE_TIMEOUT

This 6-bit field indicates TERASE and the value indicates the erase timeout from offset when multiple AUs are being erased as specified by ERASE_SIZE . The range of ERASE_TIMEOUT can be defined as up to 63 seconds and the card manufacturer can choose any combination of ERASE_SIZE and ERASE_TIMEOUT depending on the implementation. Determining ERASE_TIMEOUT determines the ERASE_SIZE .

Table 203. Erase timeout field

ERASE_TIMEOUTValue definition
00Erase timeout calculation is not supported.
011 [sec]
022 [sec]
033 [sec]
----------
6363 [sec]

ERASE_OFFSET

This 2-bit field indicates TOFFSET and one of four values can be selected. This field is meaningless if the ERASE_SIZE and ERASE_TIMEOUT fields are set to 0.

Table 204. Erase offset field

ERASE_OFFSETValue definition
0h0 [sec]
1h1 [sec]

Table 204. Erase offset field (continued)

ERASE_OFFSETValue definition
2h2 [sec]
3h3 [sec]

30.4.13 SD I/O mode

SD I/O interrupts

To allow the SD I/O card to interrupt the MultiMediaCard/SD module, an interrupt function is available on a pin on the SD interface. Pin 8, used as SDMMC_D1 when operating in the 4-bit SD mode, signals the cards interrupt to the MultiMediaCard/SD module. The use of the interrupt is optional for each card or function within a card. The SD I/O interrupt is level-sensitive, which means that the interrupt line must be held active (low) until it is either recognized and acted upon by the MultiMediaCard/SD module or deasserted due to the end of the interrupt period. After the MultiMediaCard/SD module has serviced the interrupt, the interrupt status bit is cleared via an I/O write to the appropriate bit in the SD I/O card's internal registers. The interrupt output of all SD I/O cards is active low and the application must provide pull-up resistors externally on all data lines (SDMMC_D[3:0]). The MultiMediaCard/SD module samples the level of pin 8 (SDMMC_D/IRQ) into the interrupt detector only during the interrupt period. At all other times, the MultiMediaCard/SD module ignores this value.

The interrupt period is applicable for both memory and I/O operations. The definition of the interrupt period for operations with single blocks is different from the definition for multiple-block data transfers.

SD I/O suspend and resume

Within a multifunction SD I/O or a card with both I/O and memory functions, there are multiple devices (I/O and memory) that share access to the MMC/SD bus. To share access to the MMC/SD module among multiple devices, SD I/O and combo cards optionally implement the concept of suspend/resume. When a card supports suspend/resume, the MMC/SD module can temporarily halt a data transfer operation to one function or memory (suspend) to free the bus for a higher-priority transfer to a different function or memory. After this higher-priority transfer is complete, the original transfer is resumed (restarted) where it left off. Support of suspend/resume is optional on a per-card basis. To perform the suspend/resume operation on the MMC/SD bus, the MMC/SD module performs the following steps:

  1. 1. Determines the function currently using the SDMMC_D [3:0] line(s)
  2. 2. Requests the lower-priority or slower transaction to suspend
  3. 3. Waits for the transaction suspension to complete
  4. 4. Begins the higher-priority transaction
  5. 5. Waits for the completion of the higher priority transaction
  6. 6. Restores the suspended transaction

SD I/O ReadWait

The optional ReadWait (RW) operation is defined only for the SD 1-bit and 4-bit modes. The ReadWait operation allows the MMC/SD module to signal a card that it is reading multiple

registers (IO_RW_EXTENDED, CMD53) to temporarily stall the data transfer while allowing the MMC/SD module to send commands to any function within the SD I/O device. To determine when a card supports the ReadWait protocol, the MMC/SD module must test capability bits in the internal card registers. The timing for ReadWait is based on the interrupt period.

30.4.14 Commands and responses

Application-specific and general commands

The SDMMC card host module system is designed to provide a standard interface for a variety of applications types. In this environment, there is a need for specific customer/application features. To implement these features, two types of generic commands are defined in the standard: application-specific commands (ACMD) and general commands (GEN_CMD).

When the card receives the APP_CMD (CMD55) command, the card expects the next command to be an application-specific command. ACMDs have the same structure as regular MultiMediaCard commands and can have the same CMD number. The card recognizes it as ACMD because it appears after APP_CMD (CMD55). When the command immediately following the APP_CMD (CMD55) is not a defined application-specific command, the standard command is used. For example, when the card has a definition for SD_STATUS (ACMD13), and receives CMD13 immediately following APP_CMD (CMD55), this is interpreted as SD_STATUS (ACMD13). However, when the card receives CMD7 immediately following APP_CMD (CMD55) and the card does not have a definition for ACMD7, this is interpreted as the standard (SELECT/DESELECT_CARD) CMD7.

To use one of the manufacturer-specific ACMDs the SD card Host must perform the following steps:

  1. 1. Send APP_CMD (CMD55)
    The card responds to the MultiMediaCard/SD module, indicating that the APP_CMD bit is set and an ACMD is now expected.
  2. 2. Send the required ACMD
    The card responds to the MultiMediaCard/SD module, indicating that the APP_CMD bit is set and that the accepted command is interpreted as an ACMD. When a nonACMD is sent, it is handled by the card as a normal MultiMediaCard command and the APP_CMD bit in the card status register stays clear.

When an invalid command is sent (neither ACMD nor CMD) it is handled as a standard MultiMediaCard illegal command error.

The bus transaction for a GEN_CMD is the same as the single-block read or write commands (WRITE_BLOCK, CMD24 or READ_SINGLE_BLOCK, CMD17). In this case, the argument denotes the direction of the data transfer rather than the address, and the data block has vendor-specific format and meaning.

The card must be selected (in transfer state) before sending GEN_CMD (CMD56). The data block size is defined by SET_BLOCKLEN (CMD16). The response to GEN_CMD (CMD56) is in R1b format.

Command types

Both application-specific and general commands are divided into the four following types:

Command formats

See Table 188 on page 1074 for command formats.

Commands for the MultiMediaCard/SD module

Table 205. Block-oriented write commands

CMD indexTypeArgumentResponse formatAbbreviationDescription
CMD23ac[31:16] set to 0
[15:0] number of blocks
R1SET_BLOCK_COUNTDefines the number of blocks which are going to be transferred in the multiple-block read or write command that follows.
CMD24adtc[31:0] data addressR1WRITE_BLOCKWrites a block of the size selected by the SET_BLOCKLEN command.
CMD25adtc[31:0] data addressR1WRITE_MULTIPLE_BLOCKContinuously writes blocks of data until a STOP_TRANSMISSION follows or the requested number of blocks has been received.
CMD26adtc[31:0] stuff bitsR1PROGRAM_CIDProgramming of the card identification register. This command must be issued only once per card. The card contains hardware to prevent this operation after the first programming. Normally this command is reserved for manufacturer.
CMD27adtc[31:0] stuff bitsR1PROGRAM_CSDProgramming of the programmable bits of the CSD.

Table 206. Block-oriented write protection commands

CMD indexTypeArgumentResponse formatAbbreviationDescription
CMD28ac[31:0] data addressR1bSET_WRITE_PROTIf the card has write protection features, this command sets the write protection bit of the addressed group. The properties of write protection are coded in the card-specific data (WP_GRP_SIZE).
CMD29ac[31:0] data addressR1bCLR_WRITE_PROTIf the card provides write protection features, this command clears the write protection bit of the addressed group.
CMD30adtc[31:0] write protect data addressR1SEND_WRITE_PROTIf the card provides write protection features, this command asks the card to send the status of the write protection bits.
CMD31Reserved

Table 207. Erase commands

CMD indexTypeArgumentResponse formatAbbreviationDescription
CMD32
...
CMD34
Reserved. These command indexes cannot be used in order to maintain backward compatibility with older versions of the MultiMediaCard.
CMD35ac[31:0] data addressR1ERASE_GROUP_STARTSets the address of the first erase group within a range to be selected for erase.
CMD36ac[31:0] data addressR1ERASE_GROUP_ENDSets the address of the last erase group within a continuous range to be selected for erase.
CMD37Reserved. This command index cannot be used in order to maintain backward compatibility with older versions of the MultiMediaCards
CMD38ac[31:0] stuff bitsR1ERASEErases all previously selected write blocks.

Table 208. I/O mode commands

CMD indexTypeArgumentResponse formatAbbreviationDescription
CMD39ac[31:16] RCA
[15:15] register write flag
[14:8] register address
[7:0] register data
R4FAST_IOUsed to write and read 8-bit (register) data fields. The command addresses a card and a register and provides the data for writing if the write flag is set. The R4 response contains data read from the addressed register. This command accesses application-dependent registers that are not defined in the MultiMediaCard standard.

Table 208. I/O mode commands (continued)

CMD indexTypeArgumentResponse formatAbbreviationDescription
CMD40bcr[31:0] stuff bitsR5GO_IRQ_STATEPlaces the system in the interrupt mode.
CMD41Reserved

Table 209. Lock card

CMD indexTypeArgumentResponse formatAbbreviationDescription
CMD42adtc[31:0] stuff bitsR1bLOCK_UNLOCKSets/resets the password or locks/unlocks the card. The size of the data block is set by the SET_BLOCK_LEN command.
CMD43
...
CMD54
Reserved

Table 210. Application-specific commands

CMD indexTypeArgumentResponse formatAbbreviationDescription
CMD55ac[31:16] RCA
[15:0] stuff bits
R1APP_CMDIndicates to the card that the next command bits is an application specific command rather than a standard command
CMD56adtc[31:1] stuff bits
[0]: RD/WR
--Used either to transfer a data block to the card or to get a data block from the card for general purpose/application-specific commands. The size of the data block shall be set by the SET_BLOCK_LEN command.
CMD57
...
CMD59
Reserved.
CMD60
...
CMD63
Reserved for manufacturer.

30.5 Response formats

All responses are sent via the SDMMC command line SDMMC_CMD. The response transmission always starts with the left bit of the bit string corresponding to the response code word. The code length depends on the response type.

A response always starts with a start bit (always 0), followed by the bit indicating the direction of transmission (card = 0). A value denoted by x in the tables below indicates a variable entry. All responses, except for the R3 response type, are protected by a CRC. Every command code word is terminated by the end bit (always 1).

There are five types of responses. Their formats are defined as follows:

30.5.1 R1 (normal response command)

Code length = 48 bits. The 45:40 bits indicate the index of the command to be responded to, this value being interpreted as a binary-coded number (between 0 and 63). The status of the card is coded in 32 bits.

Table 211. R1 response

Bit positionWidth (bits)ValueDescription
4710Start bit
4610Transmission bit
[45:40]6XCommand index
[39:8]32XCard status
[7:1]7XCRC7
011End bit

30.5.2 R1b

It is identical to R1 with an optional busy signal transmitted on the data line. The card may become busy after receiving these commands based on its state prior to the command reception.

30.5.3 R2 (CID, CSD register)

Code length = 136 bits. The contents of the CID register are sent as a response to the CMD2 and CMD10 commands. The contents of the CSD register are sent as a response to CMD9. Only the bits [127...1] of the CID and CSD are transferred, the reserved bit [0] of these registers is replaced by the end bit of the response. The card indicates that an erase is in progress by holding SDMMC_D0 low. The actual erase time may be quite long, and the host may issue CMD7 to deselect the card.

Table 212. R2 response

Bit positionWidth (bits)ValueDescription
13510Start bit
13410Transmission bit
[133:128]6'111111'Command index
[127:1]127XCard status
011End bit

30.5.4 R3 (OCR register)

Code length: 48 bits. The contents of the OCR register are sent as a response to CMD1. The level coding is as follows: restricted voltage windows = low, card busy = low.

Table 213. R3 response

Bit positionWidth (bits)ValueDescription
4710Start bit
4610Transmission bit
[45:40]6'111111'Reserved
[39:8]32XOCR register
[7:1]7'1111111'Reserved
011End bit

30.5.5 R4 (Fast I/O)

Code length: 48 bits. The argument field contains the RCA of the addressed card, the register address to be read out or written to, and its content.

Table 214. R4 response

Bit positionWidth (bits)ValueDescription
4710Start bit
4610Transmission bit
[45:40]6'100111'CMD39
[39:8] Argument field[31:16]16XRCA
[15:8]8Xregister address
[7:0]8Xread register contents
[7:1]7XCRC7
011End bit

30.5.6 R4b

For SD I/O only: an SDIO card receiving the CMD5 will respond with a unique SDIO response R4b. The format is:

Table 215. R4b response

Bit positionWidth (bits)ValueDescription
4710Start bit
4610Transmission bit
[45:40]6XReserved

Table 215. R4b response (continued)

Bit positionWidth (bits)ValueDescription
[39:8] Argument field3916XCard is ready
[38:36]3XNumber of I/O functions
351XPresent memory
[34:32]3XStuff bits
[31:8]24XI/O ORC
[7:1]7XReserved
011End bit

Once an SD I/O card has received a CMD5, the I/O portion of that card is enabled to respond normally to all further commands. This I/O enable of the function within the I/O card will remain set until a reset, power cycle or CMD52 with write to I/O reset is received by the card. Note that an SD memory-only card may respond to a CMD5. The proper response for a memory-only card would be Present memory = 1 and Number of I/O functions = 0. A memory-only card built to meet the SD Memory Card specification version 1.0 would detect the CMD5 as an illegal command and not respond. The I/O aware host will send CMD5. If the card responds with response R4, the host determines the card's configuration based on the data contained within the R4 response.

30.5.7 R5 (interrupt request)

Only for MultiMediaCard. Code length: 48 bits. If the response is generated by the host, the RCA field in the argument will be 0x0.

Table 216. R5 response

Bit positionWidth (bits)ValueDescription
4710Start bit
4610Transmission bit
[45:40]6'101000'CMD40
[39:8] Argument field[31:16]16XRCA [31:16] of winning card or of the host
[15:0]16XNot defined. May be used for IRQ data
[7:1]7XCRC7
011End bit

30.5.8 R6

Only for SD I/O. The normal response to CMD3 by a memory device. It is shown in Table 217 .

Table 217. R6 response

Bit positionWidth (bits)ValueDescription
4710Start bit
4610Transmission bit
[45:40]6'101000'CMD40
[39:8] Argument field[31:16]16XRCA [31:16] of winning card or of the host
[15:0]16XNot defined. May be used for IRQ data
[7:1]7XCRC7
011End bit

The card [23:8] status bits are changed when CMD3 is sent to an I/O-only card. In this case, the 16 bits of response are the SD I/O-only values:

30.6 SDIO I/O card-specific operations

The following features are SD I/O-specific operations:

The SDMMC supports these operations only if the SDMMC_DCTRL[11] bit is set, except for read suspend that does not need specific hardware implementation.

30.6.1 SDIO I/O read wait operation by SDMMC_D2 signalling

It is possible to start the readwait interval before the first block is received: when the data path is enabled (SDMMC_DCTRL[0] bit set), the SDIO-specific operation is enabled (SDMMC_DCTRL[11] bit set), read wait starts (SDMMC_DCTRL[10] = 0 and SDMMC_DCTRL[8] = 1) and data direction is from card to SDMMC (SDMMC_DCTRL[1] = 1), the DPSM directly moves from Idle to Readwait. In Readwait the DPSM drives SDMMC_D2 to 0 after 2 SDMMC_CK clock cycles. In this state, when you set the RWSTOP bit (SDMMC_DCTRL[9]), the DPSM remains in Wait for two more SDMMC_CK clock cycles to drive SDMMC_D2 to 1 for one clock cycle (in accordance with SDIO specification). The DPSM then starts waiting again until it receives data from the card. The DPSM will not start a readwait interval while receiving a block even if read wait start is set: the readwait interval will start after the CRC is received. The RWSTOP bit has to be cleared to start a new read wait operation. During the readwait interval, the SDMMC can detect SDIO interrupts on SDMMC_D1.

30.6.2 SDIO read wait operation by stopping SDMMC_CK

If the SDIO card does not support the previous read wait method, the SDMMC can perform a read wait by stopping SDMMC_CK (SDMMC_DCTRL is set just like in the method presented in Section 30.6.1 , but SDMMC_DCTRL[10] =1): DSPM stops the clock two SDMMC_CK cycles after the end bit of the current received block and starts the clock again after the read wait start bit is set.

As SDMMC_CK is stopped, any command can be issued to the card. During a read/wait interval, the SDMMC can detect SDIO interrupts on SDMMC_D1.

30.6.3 SDIO suspend/resume operation

While sending data to the card, the SDMMC can suspend the write operation. the SDMMC_CMD[11] bit is set and indicates to the CPSM that the current command is a suspend command. The CPSM analyzes the response and when the ACK is received from the card (suspend accepted), it acknowledges the DPSM that goes Idle after receiving the CRC token of the current block.

The hardware does not save the number of the remaining block to be sent to complete the suspended operation (resume).

The write operation can be suspended by software, just by disabling the DPSM (SDMMC_DCTRL[0] =0) when the ACK of the suspend command is received from the card. The DPSM enters then the Idle state.

To suspend a read: the DPSM waits in the Wait_r state as the function to be suspended sends a complete packet just before stopping the data transaction. The application continues reading RxFIFO until the FIFO is empty, and the DPSM goes Idle automatically.

30.6.4 SDIO interrupts

SDIO interrupts are detected on the SDMMC_D1 line once the SDMMC_DCTRL[11] bit is set.

When SDIO interrupt is detected, SDMMC_STA[22] (SDIOIT) bit is set. This static bit can be cleared with clear bit SDMMC_ICR[22] (SDIOITC). An interrupt can be generated when SDIOIT status bit is set. Separated interrupt enable SDMMC_MASK[22] bit (SDIOITE) is available to enable and disable interrupt request.

When SD card interrupt occurs (SDMMC_STA[22] bit set), host software follows below steps to handle it.

  1. 1. Disable SDIOIT interrupt signaling by clearing SDIOITE bit (SDMMC_MASK[22] = '0'),
  2. 2. Serve card interrupt request, and clear the source of interrupt on the SD card,
  3. 3. Clear SDIOIT bit by writing '1' to SDIOITC bit (SDMMC_ICR[22] = '1'),
  4. 4. Enable SDIOIT interrupt signaling by writing '1' to SDIOITE bit (SDMMC_MASK[22] = '1').

Steps 2 to 4 can be executed out of the SDIO interrupt service routine.

30.7 HW flow control

The HW flow control functionality is used to avoid FIFO underrun (TX mode) and overrun (RX mode) errors.

The behavior is to stop SDMMC_CK and freeze SDMMC state machines. The data transfer is stalled while the FIFO is unable to transmit or receive data. Only state machines clocked by SDMMCCLK are frozen, the APB2 interface is still alive. The FIFO can thus be filled or emptied even if flow control is activated.

To enable HW flow control, the SDMMC_CLKCR[14] register bit must be set to 1. After reset Flow Control is disabled.

30.8 SDMMC registers

The device communicates to the system via 32-bit-wide control registers accessible via APB2.

30.8.1 SDMMC power control register (SDMMC_POWER)

Address offset: 0x00

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.PWRCTRL
rwrw

Bits 31:2 Reserved, must be kept at reset value.

[1:0] PWRCTRL : Power supply control bits.

These bits are used to define the current functional state of the card clock:

00: Power-off: the clock to card is stopped.

01: Reserved

10: Reserved power-up

11: Power-on: the card is clocked.

Note: At least seven PCLK2 clock periods are needed between two write accesses to this register.

Note: After a data write, data cannot be written to this register for three SDMMCCLK clock periods plus two PCLK2 clock periods.

30.8.2 SDMMC clock control register (SDMMC_CLKCR)

Address offset: 0x04

Reset value: 0x0000 0000

The SDMMC_CLKCR register controls the SDMMC_CK output clock.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.HWFC
_EN
NEGE
DGE
WID
BUS
BYPAS
S
PWRS
AV
CLKENCLKDIV
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:15 Reserved, must be kept at reset value.

Bit 14 HWFC_EN : HW Flow Control enable

0b: HW Flow Control is disabled

1b: HW Flow Control is enabled

When HW Flow Control is enabled, the meaning of the TXFIFOE and RXFIFOE interrupt signals, see SDMMC Status register definition in Section 30.8.11 .

Bit 13 NEGEDGE : SDMMC_CK dephasing selection bit

0b: Command and Data changed on the SDMMCCLK falling edge succeeding the rising edge of SDMMC_CK. (SDMMC_CK rising edge occurs on SDMMCCLK rising edge).

1b: Command and Data changed on the SDMMC_CK falling edge.

When BYPASS is active, the data and the command change on SDMMCCLK falling edge whatever NEGEDGE value.

Bits 12:11 WIDBUS : Wide bus mode enable bit

00: Default bus mode: SDMMC_D0 used

01: 4-wide bus mode: SDMMC_D[3:0] used

10: 8-wide bus mode: SDMMC_D[7:0] used

Bit 10 BYPASS : Clock divider bypass enable bit

0: Disable bypass: SDMMCCLK is divided according to the CLKDIV value before driving the SDMMC_CK output signal.

1: Enable bypass: SDMMCCLK directly drives the SDMMC_CK output signal.

Bit 9 PWRSV : Power saving configuration bit

For power saving, the SDMMC_CK clock output can be disabled when the bus is idle by setting PWRSV:

0: SDMMC_CK clock is always enabled

1: SDMMC_CK is only enabled when the bus is active

Bit 8 CLKEN : Clock enable bit

0: SDMMC_CK is disabled

1: SDMMC_CK is enabled

Bits 7:0 CLKDIV : Clock divide factor

This field defines the divide factor between the input clock (SDMMCCLK) and the output clock (SDMMC_CK): \( SDMMC\_CK\ frequency = SDMMCCLK / [CLKDIV + 2] \) .

Note: Only even values of CLKDIV are supported (in order to have a duty cycle of 50%).

  1. Note:
    1. 1 While the SD/SDIO card or MultiMediaCard is in identification mode, the SDMMC_CK frequency must be less than 400 kHz.
    2. 2 The clock frequency can be changed to the maximum card bus frequency when relative card addresses are assigned to all cards.
    3. 3 After a data write, data cannot be written to this register for three SDMMCCLK clock periods plus two PCLK2 clock periods. SDMMC_CK can also be stopped during the read wait

interval for SD I/O cards: in this case the SDMMC_CLKCR register does not control SDMMC_CK.

30.8.3 SDMMC argument register (SDMMC_ARG)

Address offset: 0x08

Reset value: 0x0000 0000

The SDMMC_ARG register contains a 32-bit command argument, which is sent to a card as part of a command message.

31302928272625242322212019181716
CMDARG[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
CMDARG[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 CMDARG : Command argument

Command argument sent to a card as part of a command message. If a command contains an argument, it must be loaded into this register before writing a command to the command register.

30.8.4 SDMMC command register (SDMMC_CMD)

Address offset: 0x0C

Reset value: 0x0000 0000

The SDMMC_CMD register contains the command index and command type bits. The command index is sent to a card as part of a command message. The command type bits control the command path state machine (CPSM).

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.SDIO SuspendCPSM ENWAIT PENDWAIT INTWAITRESPCMDINDEX
rwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:12 Reserved, must be kept at reset value.

Bit 11 SDIOSuspend : SD I/O suspend command

If this bit is set, the command to be sent is a suspend command (to be used only with SDIO card).

Bit 10 CPSMEN : Command path state machine (CPSM) Enable bit

If this bit is set, the CPSM is enabled.

Bit 9 WAITPEND : CPSM Waits for ends of data transfer (CmdPend internal signal).

If this bit is set, the CPSM waits for the end of data transfer before it starts sending a command. This feature is available only with Stream data transfer mode SDMMC_DCTRL[2] = 1.

Bit 8 WAITINT : CPSM waits for interrupt request

If this bit is set, the CPSM disables command timeout and waits for an interrupt request.

Bits 7:6 WAITRESP : Wait for response bits

They are used to configure whether the CPSM is to wait for a response, and if yes, which kind of response.

00: No response, expect CMDSENT flag

01: Short response, expect CMDREND or CCRCFAIL flag

10: No response, expect CMDSENT flag

11: Long response, expect CMDREND or CCRCFAIL flag

Bits 5:0 CMDINDEX : Command index

The command index is sent to the card as part of a command message.

  1. Note:
    1. 1 After a data write, data cannot be written to this register for three SDMMCCLK clock periods plus two PCLK2 clock periods.
    2. 2 MultiMediaCards can send two kinds of response: short responses, 48 bits long, or long responses, 136 bits long. SD card and SD I/O card can send only short responses, the argument can vary according to the type of response: the software will distinguish the type of response according to the sent command.

30.8.5 SDMMC command response register (SDMMC_RESPCMD)

Address offset: 0x10

Reset value: 0x0000 0000

The SDMMC_RESPCMD register contains the command index field of the last command response received. If the command response transmission does not contain the command index field (long or OCR response), the RESPCMD field is unknown, although it must contain 111111b (the value of the reserved field from the response).

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.RESPCMD
rrrrrr

Bits 31:6 Reserved, must be kept at reset value.

Bits 5:0 RESPCMD : Response command index

Read-only bit field. Contains the command index of the last command response received.

30.8.6 SDMMC response 1..4 register (SDMMC_RESPx)

Address offset: (0x10 + (4 × x)); x = 1..4

Reset value: 0x0000 0000

The SDMMC_RESP1/2/3/4 registers contain the status of a card, which is part of the received response.

31302928272625242322212019181716
CARDSTATUSx[31:16]
rrrrrrrrrrrrrrrr
1514131211109876543210
CARDSTATUSx[15:0]
rrrrrrrrrrrrrrrr

Bits 31:0 CARDSTATUSx : see Table 218 .

The Card Status size is 32 or 127 bits, depending on the response type.

Table 218. Response type and SDMMC_RESPx registers

RegisterShort responseLong response
SDMMC_RESP1Card Status[31:0]Card Status [127:96]
SDMMC_RESP2UnusedCard Status [95:64]
SDMMC_RESP3UnusedCard Status [63:32]
SDMMC_RESP4UnusedCard Status [31:1]0b

The most significant bit of the card status is received first. The SDMMC_RESP4 register LSB is always 0b.

30.8.7 SDMMC data timer register (SDMMC_DTIMER)

Address offset: 0x24

Reset value: 0x0000 0000

The SDMMC_DTIMER register contains the data timeout period, in card bus clock periods.

A counter loads the value from the SDMMC_DTIMER register, and starts decrementing when the data path state machine (DPSM) enters the Wait_R or Busy state. If the timer reaches 0 while the DPSM is in either of these states, the timeout status flag is set.

31302928272625242322212019181716
DATETIME[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
DATETIME[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 DATETIME : Data timeout period

Data timeout period expressed in card bus clock periods.

Note: A data transfer must be written to the data timer register and the data length register before being written to the data control register.

30.8.8 SDMMC data length register (SDMMC_DLEN)

Address offset: 0x28

Reset value: 0x0000 0000

The SDMMC_DLEN register contains the number of data bytes to be transferred. The value is loaded into the data counter when data transfer starts.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.DATALENGTH[24:16]
rwrwrwrwrwrwrwrwrw
1514131211109876543210
DATALENGTH[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:25 Reserved, must be kept at reset value.

Bits 24:0 DATALENGTH : Data length value

Number of data bytes to be transferred.

Note: For a block data transfer, the value in the data length register must be a multiple of the block size (see SDMMC_DCTRL ). Before being written to the data control register a timeout must be written to the data timer register and the data length register.

In case of IO_RW_EXTENDED (CMD53):

- If the Stream or SDIO multibyte data transfer is selected the value in the data length register must be between 1 and 512.

- If the Block data transfer is selected the value in the data length register must be between 1*Data block size and 512*Data block size.

30.8.9 SDMMC data control register (SDMMC_DCTRL)

Address offset: 0x2C

Reset value: 0x0000 0000

The SDMMC_DCTRL register control the data path state machine (DPSM).

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.SDIO ENRW MODRW STOPRW STARTDBLOCKSIZEDMA ENDT MODEDTDIRDTEN
rwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:12 Reserved, must be kept at reset value.

Bit 11 SDIOEN : SD I/O enable functions

If this bit is set, the DPSM performs an SD I/O-card-specific operation.

Bit 10 RWMOD : Read wait mode

0: Read Wait control stopping SDMMC_D2

1: Read Wait control using SDMMC_CK

Bit 9 RWSTOP : Read wait stop

0: Read wait in progress if RWSTART bit is set

1: Enable for read wait stop if RWSTART bit is set

Bit 8 RWSTART : Read wait start

If this bit is set, read wait operation starts.

Bits 7:4 DBLOCKSIZE : Data block size

Define the data block length when the block data transfer mode is selected:

0000: (0 decimal) lock length = \( 2^0 = 1 \) byte

0001: (1 decimal) lock length = \( 2^1 = 2 \) bytes

0010: (2 decimal) lock length = \( 2^2 = 4 \) bytes

0011: (3 decimal) lock length = \( 2^3 = 8 \) bytes

0100: (4 decimal) lock length = \( 2^4 = 16 \) bytes

0101: (5 decimal) lock length = \( 2^5 = 32 \) bytes

0110: (6 decimal) lock length = \( 2^6 = 64 \) bytes

0111: (7 decimal) lock length = \( 2^7 = 128 \) bytes

1000: (8 decimal) lock length = \( 2^8 = 256 \) bytes

1001: (9 decimal) lock length = \( 2^9 = 512 \) bytes

1010: (10 decimal) lock length = \( 2^{10} = 1024 \) bytes

1011: (11 decimal) lock length = \( 2^{11} = 2048 \) bytes

1100: (12 decimal) lock length = \( 2^{12} = 4096 \) bytes

1101: (13 decimal) lock length = \( 2^{13} = 8192 \) bytes

1110: (14 decimal) lock length = \( 2^{14} = 16384 \) bytes

1111: (15 decimal) reserved

Bit 3 DMAEN : DMA enable bit

0: DMA disabled.

1: DMA enabled.

Bit 2 DTMODE : Data transfer mode selection 1: Stream or SDIO multibyte data transfer.

0: Block data transfer

1: Stream or SDIO multibyte data transfer

Bit 1 DTDIR : Data transfer direction selection

0: From controller to card.

1: From card to controller.

[0] DTEN : Data transfer enabled bit

Data transfer starts if 1b is written to the DTEN bit. Depending on the direction bit, DTDIR, the DPSM moves to the Wait_S, Wait_R state or Readwait if RW Start is set immediately at the beginning of the transfer. It is not necessary to clear the enable bit after the end of a data transfer but the SDMMC_DCTRL must be updated to enable a new data transfer

Note: After a data write, data cannot be written to this register for three SDMMCCLK clock periods plus two PCLK2 clock periods.

The meaning of the DTMODE bit changes according to the value of the SDIOEN bit. When SDIOEN=0 and DTMODE=1, the MultiMediaCard stream mode is enabled, and when SDIOEN=1 and DTMODE=1, the peripheral enables an SDIO multibyte transfer.

30.8.10 SDMMC data counter register (SDMMC_DCOUNT)

Address offset: 0x30

Reset value: 0x0000 0000

The SDMMC_DCOUNT register loads the value from the data length register (see SDMMC_DLEN) when the DPSM moves from the Idle state to the Wait_R or Wait_S state. As data is transferred, the counter decrements the value until it reaches 0. The DPSM then moves to the Idle state and the data status end flag, DATAEND, is set.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.DATACOUNT[24:16]
rrrrrrrrr
1514131211109876543210
DATACOUNT[15:0]
rrrrrrrrrrrrrrrr

Bits 31:25 Reserved, must be kept at reset value.

Bits 24:0 DATACOUNT : Data count value

When this bit is read, the number of remaining data bytes to be transferred is returned. Write has no effect.

Note: This register should be read only when the data transfer is complete.

30.8.11 SDMMC status register (SDMMC_STA)

Address offset: 0x34

Reset value: 0x0000 0000

The SDMMC_STA register is a read-only register. It contains two types of flag:

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.SDIOITRXD AVLTXD AVLRX FIFOETX FIFOERX FIFOFTX FIFOF
rrrrrrr
1514131211109876543210
RX FIFO HFTX FIFO HERXACTTXACTCMD ACTDBCK ENDRes.DATA ENDCMDS ENTCMR ENDRX OVERRTXUND ERRDTIME OUTCTIME OUTDCRC FAILCCRC FAIL
rrrrrrrrrrrrrrr

Bits 31:23 Reserved, must be kept at reset value.

Bit 22 SDIOIT : SDIO interrupt received

Bit 21 RXDAVL : Data available in receive FIFO

Bit 20 TXDAVL : Data available in transmit FIFO

Bit 19 RXFIFOE : Receive FIFO empty

Bit 18 TXFIFOE : Transmit FIFO empty

When HW Flow Control is enabled, TXFIFOE signals becomes activated when the FIFO contains 2 words.

Bit 17 RXFIFOF : Receive FIFO full

When HW Flow Control is enabled, RXFIFOF signals becomes activated 2 words before the FIFO is full.

Bit 16 TXFIFOF : Transmit FIFO full

Bit 15 RXFIFOHF : Receive FIFO half full: there are at least 8 words in the FIFO

Bit 14 TXFIFOHE : Transmit FIFO half empty: at least 8 words can be written into the FIFO

Bit 13 RXACT : Data receive in progress

Bit 12 TXACT : Data transmit in progress

Bit 11 CMDACT : Command transfer in progress

Bit 10 DBCKEND : Data block sent/received (CRC check passed)

Bit 9 Reserved, must be kept at reset value.

Bit 8 DATAEND : Data end (data counter, SDIDCOUNT, is zero)

Bit 7 CMDSENT : Command sent (no response required)

Bit 6 CMDREND : Command response received (CRC check passed)

Bit 5 RXOVERR : Received FIFO overrun error

Note: If DMA is used to read SDMMC FIFO (DMAEN bit is set in SDMMC_DCTRL register), user software should disable DMA stream, and then write with '0' (to disable DMA request generation).

Bit 4 TXUNDERR : Transmit FIFO underrun error

Note: If DMA is used to fill SDMMC FIFO (DMAEN bit is set in SDMMC_DCTRL register), user software should disable DMA stream, and then write DMAEN with '0' (to disable DMA request generation).

Bit 3 DTIMEOUT : Data timeout

Bit 2 CTIMEOUT : Command response timeout

The Command TimeOut period has a fixed value of 64 SDMMC_CK clock periods.

Bit 1 DCRCFAIL : Data block sent/received (CRC check failed)

Bit 0 CCRCFAIL : Command response received (CRC check failed)

30.8.12 SDMMC interrupt clear register (SDMMC_ICR)

Address offset: 0x38

Reset value: 0x0000 0000

The SDMMC_ICR register is a write-only register. Writing a bit with 1b clears the corresponding bit in the SDMMC_STA Status register.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.SDIO ITCRes.Res.Res.Res.Res.Res.
rw
1514131211109876543210
Res.Res.Res.Res.Res.DBCK ENDCRes.DATA ENDCCMD SENTCCMD REND CRX OVERR CTX UNDERR CDTIME OUTCCTIME OUTCDCRC FAILCCCRC FAILC
rwrwrwrwrwrwrwrwrwrw

Bits 31:23 Reserved, must be kept at reset value.

Bit 22 SDIOITC : SDIOIT flag clear bit

Set by software to clear the SDIOIT flag.

0: SDIOIT not cleared

1: SDIOIT cleared

Bits 21:11 Reserved, must be kept at reset value.

Bit 10 DBCKENDC : DBCKEND flag clear bit

Set by software to clear the DBCKEND flag.

0: DBCKEND not cleared

1: DBCKEND cleared

Bit 9 Reserved, must be kept at reset value.

Bit 8 DATAENDC : DATAEND flag clear bit

Set by software to clear the DATAEND flag.

0: DATAEND not cleared

1: DATAEND cleared

Bit 7 CMDSENTC : CMDSENT flag clear bit

Set by software to clear the CMDSENT flag.

0: CMDSENT not cleared

1: CMDSENT cleared

Bit 6 CMDRENDC : CMDREND flag clear bit

Set by software to clear the CMDREND flag.

0: CMDREND not cleared

1: CMDREND cleared

Bit 5 RXOVERRC : RXOVERR flag clear bit

Set by software to clear the RXOVERR flag.

0: RXOVERR not cleared

1: RXOVERR cleared

Bit 4 TXUNDERRC : TXUNDERR flag clear bit

Set by software to clear TXUNDERR flag.

0: TXUNDERR not cleared

1: TXUNDERR cleared

Bit 3 DTIMEOUTC : DTIMEOUT flag clear bit

Set by software to clear the DTIMEOUT flag.

0: DTIMEOUT not cleared

1: DTIMEOUT cleared

Bit 2 CTIMEOUTC : CTIMEOUT flag clear bit

Set by software to clear the CTIMEOUT flag.

0: CTIMEOUT not cleared

1: CTIMEOUT cleared

Bit 1 DCRCFAILC : DCRCFAIL flag clear bit

Set by software to clear the DCRCFAIL flag.

0: DCRCFAIL not cleared

1: DCRCFAIL cleared

Bit 0 CCRCFAILC : CCRCFAIL flag clear bit

Set by software to clear the CCRCFAIL flag.

0: CCRCFAIL not cleared

1: CCRCFAIL cleared

30.8.13 SDMMC mask register (SDMMC_MASK)

Address offset: 0x3C

Reset value: 0x0000 0000

The interrupt mask register determines which status flags generate an interrupt request by setting the corresponding bit to 1b.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.SDIO
ITIE
RXD
AVLIE
TXD
AVLIE
RX
FIFO
EIE
TX
FIFO
EIE
RX
FIFO
FIE
TX
FIFO
FIE
rwrwrwrwrwrwrw

1514131211109876543210
RX
FIFO
HFIE
TX
FIFO
HEIE
RX
ACTIE
TX
ACTIE
CMD
ACTIE
DBCK
ENDIE
Res.DATA
ENDIE
CMD
SENT
IE
CMD
REND
IE
RX
OVERR
IE
TX
UNDERR
IE
DTIME
OUTIE
CTIME
OUTIE
DCRC
FAILIE
CCRC
FAILIE
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:23 Reserved, must be kept at reset value.

Bit 22 SDIOITIE : SDIO mode interrupt received interrupt enable

Set and cleared by software to enable/disable the interrupt generated when receiving the SDIO mode interrupt.

0: SDIO Mode Interrupt Received interrupt disabled

1: SDIO Mode Interrupt Received interrupt enabled

Bit 21 RXDVLIE : Data available in Rx FIFO interrupt enable

Set and cleared by software to enable/disable the interrupt generated by the presence of data available in Rx FIFO.

0: Data available in Rx FIFO interrupt disabled

1: Data available in Rx FIFO interrupt enabled

Bit 20 TXDVLIE : Data available in Tx FIFO interrupt enable

Set and cleared by software to enable/disable the interrupt generated by the presence of data available in Tx FIFO.

0: Data available in Tx FIFO interrupt disabled

1: Data available in Tx FIFO interrupt enabled

  1. Bit 19 RXFIFOEIE : Rx FIFO empty interrupt enable
    Set and cleared by software to enable/disable interrupt caused by Rx FIFO empty.
    0: Rx FIFO empty interrupt disabled
    1: Rx FIFO empty interrupt enabled
  2. Bit 18 TXFIFOEIE : Tx FIFO empty interrupt enable
    Set and cleared by software to enable/disable interrupt caused by Tx FIFO empty.
    0: Tx FIFO empty interrupt disabled
    1: Tx FIFO empty interrupt enabled
  3. Bit 17 RXFIFOFIE : Rx FIFO full interrupt enable
    Set and cleared by software to enable/disable interrupt caused by Rx FIFO full.
    0: Rx FIFO full interrupt disabled
    1: Rx FIFO full interrupt enabled
  4. Bit 16 TXFIFOFIE : Tx FIFO full interrupt enable
    Set and cleared by software to enable/disable interrupt caused by Tx FIFO full.
    0: Tx FIFO full interrupt disabled
    1: Tx FIFO full interrupt enabled
  5. Bit 15 RXFIFOHFIE : Rx FIFO half full interrupt enable
    Set and cleared by software to enable/disable interrupt caused by Rx FIFO half full.
    0: Rx FIFO half full interrupt disabled
    1: Rx FIFO half full interrupt enabled
  6. Bit 14 TXFIFOHEIE : Tx FIFO half empty interrupt enable
    Set and cleared by software to enable/disable interrupt caused by Tx FIFO half empty.
    0: Tx FIFO half empty interrupt disabled
    1: Tx FIFO half empty interrupt enabled
  7. Bit 13 RXACTIE : Data receive acting interrupt enable
    Set and cleared by software to enable/disable interrupt caused by data being received (data receive acting).
    0: Data receive acting interrupt disabled
    1: Data receive acting interrupt enabled
  8. Bit 12 TXACTIE : Data transmit acting interrupt enable
    Set and cleared by software to enable/disable interrupt caused by data being transferred (data transmit acting).
    0: Data transmit acting interrupt disabled
    1: Data transmit acting interrupt enabled
  9. Bit 11 CMDACTIE : Command acting interrupt enable
    Set and cleared by software to enable/disable interrupt caused by a command being transferred (command acting).
    0: Command acting interrupt disabled
    1: Command acting interrupt enabled
  10. Bit 10 DBCKENDIE : Data block end interrupt enable
    Set and cleared by software to enable/disable interrupt caused by data block end.
    0: Data block end interrupt disabled
    1: Data block end interrupt enabled
  11. Bit 9 Reserved, must be kept at reset value.
  1. Bit 8 DATAENDIE : Data end interrupt enable
    Set and cleared by software to enable/disable interrupt caused by data end.
    0: Data end interrupt disabled
    1: Data end interrupt enabled
  2. Bit 7 CMDSENTIE : Command sent interrupt enable
    Set and cleared by software to enable/disable interrupt caused by sending command.
    0: Command sent interrupt disabled
    1: Command sent interrupt enabled
  3. Bit 6 CMDRENDIE : Command response received interrupt enable
    Set and cleared by software to enable/disable interrupt caused by receiving command response.
    0: Command response received interrupt disabled
    1: command Response Received interrupt enabled
  4. Bit 5 RXOVERRIE : Rx FIFO overrun error interrupt enable
    Set and cleared by software to enable/disable interrupt caused by Rx FIFO overrun error.
    0: Rx FIFO overrun error interrupt disabled
    1: Rx FIFO overrun error interrupt enabled
  5. Bit 4 TXUNDERRIE : Tx FIFO underrun error interrupt enable
    Set and cleared by software to enable/disable interrupt caused by Tx FIFO underrun error.
    0: Tx FIFO underrun error interrupt disabled
    1: Tx FIFO underrun error interrupt enabled
  6. Bit 3 DTIMEOUTIE : Data timeout interrupt enable
    Set and cleared by software to enable/disable interrupt caused by data timeout.
    0: Data timeout interrupt disabled
    1: Data timeout interrupt enabled
  7. Bit 2 CTIMEOUTIE : Command timeout interrupt enable
    Set and cleared by software to enable/disable interrupt caused by command timeout.
    0: Command timeout interrupt disabled
    1: Command timeout interrupt enabled
  8. Bit 1 DCRCFAILIE : Data CRC fail interrupt enable
    Set and cleared by software to enable/disable interrupt caused by data CRC failure.
    0: Data CRC fail interrupt disabled
    1: Data CRC fail interrupt enabled
  9. Bit 0 CCRCFAILIE : Command CRC fail interrupt enable
    Set and cleared by software to enable/disable interrupt caused by command CRC failure.
    0: Command CRC fail interrupt disabled
    1: Command CRC fail interrupt enabled

30.8.14 SDMMC FIFO counter register (SDMMC_FIFOCNT)

Address offset: 0x48

Reset value: 0x0000 0000

The SDMMC_FIFOCNT register contains the remaining number of words to be written to or read from the FIFO. The FIFO counter loads the value from the data length register (see SDMMC_DLEN) when the data transfer enable bit, DTEN, is set in the data control register (SDMMC_DCTRL register) and the DPSM is at the Idle state. If the data length is not word-aligned (multiple of 4), the remaining 1 to 3 bytes are regarded as a word.

31302928272625242322212019181716
ResResResResResResResResFIFOCOUNT[23:16]
rrrrrrrr
1514131211109876543210
FIFOCOUNT[15:0]
rrrrrrrrrrrrrrrr

Bits 31:24 Reserved, must be kept at reset value.

Bits 23:0 FIFOCOUNT : Remaining number of words to be written to or read from the FIFO.

30.8.15 SDMMC data FIFO register (SDMMC_FIFO)

Address offset: 0x80

Reset value: 0x0000 0000

The receive and transmit FIFOs can be read or written as 32-bit wide registers. The FIFOs contain 32 entries on 32 sequential addresses. This allows the CPU to use its load and store multiple operands to read from/write to the FIFO.

31302928272625242322212019181716
FIFOData[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
FIFOData[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

bits 31:0 FIFOData : Receive and transmit FIFO data

The FIFO data occupies 32 entries of 32-bit words, from address:
SDMMC base + 0x080 to SDMMC base + 0xFC.

30.8.16 SDMMC register map

The following table summarizes the SDMMC registers.

Table 219. SDMMC register map

OffsetRegister313029282726252423222120191817161514131211109876543210
0x00SDMMC_POWERRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.PWRCTRL
Reset value0 0
0x04SDMMC_CLKCRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.HWFC_ENNEGEDGEWIDBUSBYPASSPWRSVCLKENCLKDIV
Reset value000000
0x08SDMMC_ARGCMDARG
Reset value00000000000000000000000000000000
0x0CSDMMC_CMDRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SDIOSuspendCPSMENWAITPENDWAITINTWAITRESPCMDINDEX
Reset value00000
0x10SDMMC_RESPCMDRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.RESPCMD
Reset value
0x14SDMMC_RESP1CARDSTATUS1
Reset value00000000000000000000000000000000
0x18SDMMC_RESP2CARDSTATUS2
Reset value00000000000000000000000000000000
0x1CSDMMC_RESP3CARDSTATUS3
Reset value00000000000000000000000000000000
0x20SDMMC_RESP4CARDSTATUS4
Reset value00000000000000000000000000000000
0x24SDMMC_DTIMERDATETIME
Reset value00000000000000000000000000000000
0x28SDMMC_DLENRes.Res.Res.Res.Res.Res.Res.DATALENGTH
Reset value
0x2CSDMMC_DCTRLRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SDIOENRWMODRWSTOPRWSTARTDBLOCKSIZEDMAENDTMODEDTDIRDTEN
Reset value00000000

Table 219. SDMMC register map (continued)

OffsetRegister313029282726252423222120191817161514131211109876543210
0x30SDMMC_DCOUNTDATACOUNT
Reset valueResResResResResResRes0000000000000000000000000
0x34SDMMC_STAResResResResResResResResResSDIOITRXDAVLTXDAVLRXFIFOETXFIFOERXFIFOTXFIFORXFIFOHTXFIFOHRXACTTXACTCMDACTDBCKENDResDATAENDCMDSENTCMDRENDRXOVERTXUNDERDTIMEOUTCTIMEOUTDCRCFAILCCRCFAIL
Reset value000000000000000000000
0x38SDMMC_ICRResResResResResResResResResSDIOITCResResResResResResResResResResResDBCKENDCResDATAENDCCMDSENTCCMDRENCRXOVERCTXUNDERCDTIMEOUTCCTIMEOUTCDCRCFAILCCCRCFAILC
Reset value00000000000
0x3CSDMMC_MASKResResResResResResResResResSDIOITIERXDAVLIETXDAVLIERXFIFOIETXFIFOIERXFIFOIETXFIFOIERXFIFOHIETXFIFOHIERXACTIETXACTIECMDACTIEDBCKENDIEResDATAENDIECMDSENTIECMDRENDIERXOVERIETXUNDERIEDTIMEOUTIECTIMEOUTIEDCRCFAILIECCRCFAILIE
Reset value000000000000000000000
0x48SDMMC_FIFOCNTFIFOCOUNT
Reset valueResResResResResResRes0000000000000000000000000
0x80SDMMC_FIFOFIFOData
Reset value00000000000000000000000000000000
Refer to Section 1.6 on page 56 for the register boundary addresses.