English
Language : 

SAM9G25_14 Datasheet, PDF (629/1167 Pages) ATMEL Corporation – Atmel | SMART ARM-based Embedded Microprocessor
Figure 34-9. Write Functional Flow Diagram
Send SELECT/DESELECT_CARD
command(1) to select the card
Send SET_BLOCKLEN command(1)
No
Write using DMAC
Reset theDMAEN bit
HSMCI_DMA &= ~DMAEN
Set the block length (in bytes)
HSMCI_MR |= (BlockLength) <<16)(2)
Set the block count (if necessary)
HSMCI_BLKR |= (BlockCount << 0)
Send WRITE_SINGLE_BLOCK
command(1)
Yes
Set the DMAEN bit
HSMCI_DMA |= DMAEN
Set the block length (in bytes)
HSMCI_BLKR |= (BlockLength << 16)(2)
Send WRITE_SINGLE_BLOCK
command(1)
Number of words to write = BlockLength/4
Yes
Number of words to write = 0 ?
No
Read status register HSMCI_SR
Poll the bit
Yes
TXRDY = 0?
No
HSMCI_TDR = Data to write
Number of words to write =
Number of words to write -1
Configure the DMA channel X
DMAC_DADDRx = Data Address to write
DMAC_BTSIZE = BlockLength/4
DMAC_CHEN[X] = TRUE
Read status register HSMCI_SR
Poll the bit
Yes
XFRDONE = 0?
No
RETURN
RETURN
Note:
1. It is assumed that this command has been correctly sent (see Figure 34-7).
2. This field is also accessible in the HSMCI Block Register (HSMCI_BLKR).
The following flowchart (Figure 34-10) shows how to manage read multiple block and write multiple block transfers with
the DMA Controller. Polling or interrupt method can be used to wait for the end of write according to the contents of the
Interrupt Mask Register (HSMCI_IMR).
SAM9G25 [DATASHEET]
Atmel-11032E-ATARM-SAMG25-Datasheet_13-Oct-14
1629