Datasheet

2017 Microchip Technology Inc. DS60001516A-page 577
SAM9G20
Figure 34-11: Write Functional Flow Diagram
Note 1: It is assumed that this command has been correctly sent (see Figure 34-9).
2: This field is also accessible in the MCI Block Register (MCI_BLKR).
Send SELECT/DESELECT_CARD
command
(1)
to select the card
Send SET_BLOCKLEN command
(1)
Write using PDC
Send WRITE_SINGLE_BLOCK
command
(1)
Configure the PDC channel
MCI_TPR = Data Buffer Address to write
MCI_TCR = BlockLength/4
Send WRITE_SINGLE_BLOCK
command
(1)
Read status register MCI_SR
Poll the bit
NOTBUSY= 0?
Ye s
No
Ye s
No
Read status register MCI_SR
Number of words to write = 0 ?
Poll the bit
TXRDY = 0?
MCI_TDR = Data to write
Number of words to write =
Number of words to write -1
Ye s
RETURN
No
Ye s
No
Number of words to write = BlockLength/4
MCI_PTCR = TXTEN
Reset the PDCMODE bit
MCI_MR &= ~PDCMODE
Set the block length (in bytes)
MCI_MR |= (BlockLenght <<16)
(2)
Set the block count (if necessary)
MCI_BLKR |= (BlockCount << 0)
Set the PDCMODE bit
MCI_MR |= PDCMODE
Set the block length (in bytes)
MCI_BLKR |= (BlockLength << 16)
(2)
RETURN