English
Language : 

PIC32MX440F256H-80I Datasheet, PDF (231/646 Pages) Microchip Technology – 64/100-Pin General Purpose and USB 32-Bit Flash Microcontrollers
PIC32MX3XX/4XX
EXAMPLE 10-1: CONFIGURING THE DMA FOR BASIC TRANSFER MODE OPERATION
/*
The following code example illustrates the DMA channel 0 configuration for a basic transfer.
*/
IEC1CLR=0x00010000;
// disable DMA channel 0 interrupts
IFS1CLR=0x00010000;
// clear existing DMA channel 0 interrupt flag
DMACONSET=0x00008000;
DCH0CON=0x3;
// enable the DMA controller
// channel off, pri 3, no chaining
CH0ECON=0;
// no start or stop irq’s, no pattern match
DCH0SSA=0x1d010000;
DCH0DSA=0x1d020000;
DCH0SSIZ=0;
DCH0DSIZ=0;
DCH0CSIZ=0;
// program the transfer
// transfer source physical address
// transfer destination physical address
// source size 256 bytes
// destination size 256 bytes
// 256 bytes transferred per event
DCH0INTCLR=0x00ff00ff;
DCH0CONSET=0x80;
// clear existing events, disable all interrupts
// turn channel on
DCH0ECONSET=0x00000080;
// initiate a transfer
// set CFORCE to 1
// do something else
// poll to see that the transfer was done
while(TRUE)
{
register int pollCnt;
// use a poll counter.
// polling continuously the DMA controller in a tight
// loop would affect the performance of the DMA transfer
int dmaFlags=DCH0INT;
if( (dmaFlags&0xb)
{
// one of CHERIF (DCHxINT<0>), CHTAIF (DCHxINT<1>)
// or CHBCIF (DCHxINT<3>) flags set
break;
// transfer completed
}
pollCnt=100;
// use an adjusted value here
while(pollCnt--);
// wait before reading again the DMA controller
}
// check the transfer completion result
© 2008 Microchip Technology Inc.
Preliminary
DS61143E-page 229