Datasheet

281
SAM9263 [DATASHEET]
Atmel-6249N-ATARM-SAM9263-Datasheet_14-Mar-16
Multi-block Transfer with Source Address Auto-reloaded and Contiguous Destination Address (Row 3)
1. Read the Channel Enable register to choose a free (disabled) channel.
2. Clear any pending interrupts on the channel from the previous DMA transfer by writing to the Interrupt Clear
registers: DMAC_ClearTfr, DMAC_ClearBlock, DMAC_ClearSrcTran, DMAC_ClearDstTran,
DMAC_ClearErr. Reading the Interrupt Raw Status and Interrupt Status registers confirms that all interrupts
have been cleared.
3. Program the following channel registers:
1. Write the starting source address in the DMAC_SARx for channel x.
2. Write the starting destination address in the DMAC_DARx for channel x.
3. Program DMAC_CTLx and DMAC_CFGx according to Row 3 as shown in Table 24-2 on page 268. Pro-
gram the DMAC_LLPx register with ‘0’.
4. Write the control information for the DMA transfer in the DMAC_CTLx register for channel x. For example, in
this register, you can program the following:
i. Set up the transfer type (memory or non-memory peripheral for source and destination) and flow
control device by programming the TT_FC of the DMAC_CTLx register.
ii. Set up the transfer characteristics, such as:
Transfer width for the source in the SRC_TR_WIDTH field.
Transfer width for the destination in the DST_TR_WIDTH field.
Source master layer in the SMS field where source resides.
Destination master layer in the DMS field where destination resides.
Incrementing/decrementing or fixed address for source in SINC field.
Incrementing/decrementing or fixed address for destination in DINC field.
5. If gather is enabled (DMAC_CTLx.S_GATH_EN is enabled), program the DMAC_SGRx for channel x.
6. If scatter is enabled (DMAC_CTLx.D_SCAT_EN), program the DMAC_DSRx for channel x.
7. Write the channel configuration information into the DMAC_CFGx register for channel x.
i. Designate the handshaking interface type (hardware or software) for the source and destination
peripherals. This is not required for memory. This step requires programming the
HS_SEL_SRC/HS_SEL_DST bits, respectively. Writing a ‘0’ activates the hardware handshaking
interface to handle source/destination requests for the specific channel. Writing a ‘1’ activates the
software handshaking interface to handle source/destination requests.
ii. If the hardware handshaking interface is activated for the source or destination peripheral, assign
handshaking interface to the source and destination peripheral. This requires programming the
SRC_PER and DEST_PER bits, respectively.
4. After the DMAC channel has been programmed, enable the channel by writing a ‘1’ to the
DMAC_ChEnReg.CH_EN bit. Make sure that bit 0 of the DMAC_DmaCfgReg register is enabled.
5. Source and destination request single and burst DMAC transactions to transfer the block of data (assuming
non-memory peripherals). The DMAC acknowledges at the completion of every transaction (burst and
single) in the block and carries out the block transfer.
6. When the block transfer has completed, the DMAC reloads the DMAC_SARx. The DMAC_DARx remains
unchanged. Hardware sets the block complete interrupt. The DMAC then samples the row number as shown
in Table 24-2 on page 268. If the DMAC is in Row 1, then the DMA transfer has completed. Hardware sets
the transfer complete interrupt and disables the channel. So you can either respond to the Block Complete
or Transfer Complete interrupts, or poll for the Channel Enable (DMAC_ChEnReg.CH_EN) bit until it is
cleared by hardware, to detect when the transfer is complete. If the DMAC is not in Row 1, the next step is
performed.