13.4.8.4 Continuous Mode
In Continuous mode (TRMODE[1:0] = 10
), a single trigger starts a
sequence of back-to-back transfers; these continue with each transfer decrementing
DMAxCNT until it reaches 0000h. At this point, like One-Shot mode, the channel is
disabled.
One-Shot and Continuous modes are similar in that each mode performs a certain number of transfers for one time. The difference is that One-Shot mode requires a trigger for each transfer, while Continuous mode allows many transfers for each trigger. In addition, DMAxCNT is controlled by the number of individual transactions, not the number of triggers.
Typical Code Sequence for a Continuous Transfer shows a typical code sequence for a Continuous transfer.
Typical Code Sequence for a Continuous Transfer
unsigned int SRC[100];
unsigned int DEST[100];
int main()
{
for (int i=0;i<100;i++)
{
SRC[i]=i+1; //fill with i+1
DEST[i]=0; //fill with 0
}
DMACONbits.ON=1;
DMACONbits.PRIORITY=1;
IFS2bits.DMA0IF=0;
DMAHIGH=0x5000; //set lower and upper address limit
DMALOW=0x4000;
DMA0SRC=(unsigned int)& SRC; // load the source address
DMA0DST=(unsigned int)& DEST; // load destination address
DMA0CNT=0x64; //CNT = 100
DMA0CHbits.SAMODE=1; //Source address increment mode
DMA0CHbits.DAMODE=1; //Destination address increment mode
DMA0CHbits.TRMODE=2; //Transfer mode Continuous
DMA0CHbits.SIZE = 2; //32-bit transfer per count
DMA0CHbits.CHEN=1; //Channel enable
DMA0CHbits.CHREQ=1; //Enable the transfer by software trigger
while(!DMA0STATbits.DONE); //DONE=1;CHEN=0,DMA0IF=1
//100 (DMAXCNT=100)transfer complete with one trigger
IFS2bits.DMA0IF=0;
while(1);
}