Datasheet

© 2007 Microchip Technology Inc. Preliminary DS70165E-page 139
dsPIC33F
7.4 DMA Initialization Example
The following is a DMA initialization example:
EXAMPLE 7-1: DMA SAMPLE INITIALIZATION METHOD
// Clear all DMA controller status bits to a known state
DMACS0 = 0;
// Set up DMA Channel 0: Word mode, Read from Peripheral & Write to DMA; Interrupt when all the
data has been moved; Indirect with post-increment; Continuous mode with Ping-Pong Disabled
DMA0CON = 0x0000;
//Automatic DMA transfer initiation by DMA request; DMA Peripheral IRQ Number set up for ADC1
DMA0REQ = 0x000D;
// Set up offset into DMA RAM so that the buffer that collects ADC result data starts at the base
of DMA RAM
DMA0STA = 0x0000;
// DMA0PAD should be loaded with the address of the ADC conversion result register
DMA0PAD = (volatile unsigned int) &ADC1BUF0;
// DMA transfer of 256 words of data
DMA0CNT = 0x0100 ;
//Clear the DMA0 Interrupt Flag
IFS0bits.DMA0IF = 0;
//Enable DMA0 Interrupts
IEC0bits.DMA0IE = 1;
//Enable the DMA0 Channel
DMA0CONbits.CHEN = 1;