Agilex™ 7 Hard Processor System Technical Reference Manual

ID 683567
Date 8/13/2024
Public
Document Table of Contents

16.5.5.5. Single-Block or Multiple-Block Write

The following steps comprise a single‑block or multiple‑block write:
  1. Write the data size in bytes to the bytcnt register. For a multi‑block write, bytcnt must be a multiple of the block size.
  2. Write the block size in bytes to the blksiz register. The controller sends data in blocks of size blksiz each.
  3. Write the cmdarg register with the data address to which data must be written.
  4. Write data into the FIFO buffer. For best performance, the host software should write data continuously until the FIFO buffer is full.
  5. Write the cmd register with the parameters listed in cmd Register Settings for Single-Block and Multiple-Block Write. For SD and MMC cards, use the SD/SDIO WRITE_BLOCK (CMD24) command for a single‑block write and the WRITE_MULTIPLE_BLOCK (CMD25) command for a multiple‑block writes. For SDIO cards, use the IO_RW_EXTENDED command for both single‑block and multiple‑block transfers.

    After writing to the cmd register, the controller starts executing a command if there is no other command already being processed. When the command is sent to the bus, a Command Done interrupt is generated.

  6. Software must check for data error interrupts; that is, for dcrc, bds, and ebe bits of the rintsts register. If required, software can terminate the data transfer early by sending the SD/SDIO STOP command.
  7. Software must check for host timeout conditions in the rintsts register:
    • Transmit FIFO buffer data request.
    • Data starvation by the host—the controller wrote data to the card faster than the host could supply the data.

    In both cases, the software must write data into the FIFO buffer.

    There are two types of transfers: open‑ended and fixed length.

    • Open‑ended transfers—For an open‑ended block transfer, the byte count is 0. At the end of the data transfer, software must send the STOP_TRANSMISSION command (CMD12).
    • Fixed‑length transfers—The byte count is nonzero. You must already have written the number of bytes to the bytcnt register. The controller issues the STOP command for you if you set the send_auto_stop bit of the cmd register to 1. After completion of a transfer of a given number of bytes, the controller sends the STOP command. Completion of the AUTO_STOP command is reflected by the Auto Command Done interrupt. A response to the AUTO_STOP command is written to the resp1 register. If software does not set the send_auto_stop bit in the cmd register to 1, software must issue the STOP command just like in the open‑ended case.

When the dto bit of the rintsts register is set, the data command is complete.