Specifications
dsPIC33F Family Reference Manual
DS70183A-page 16-60 © 2006 Microchip Technology Inc.
Example 16-5: Code for Alternate Sampling Using DMA (Continued)
DMA0REQ=13;
DMA0STA = __builtin_dmaoffset(&BufferA[0][0]);
DMA0STB = __builtin_dmaoffset(&BufferB[0][0]);
IFS0bits.DMA0IF = 0; //Clear the DMA interrupt flag bit
IEC0bits.DMA0IE = 1; //Set the DMA interrupt enable bit
DMA0CONbits.CHEN=1;
}
/*=======================================================================================
_DMA0Interrupt(): ISR name is chosen from the device linker script.
=======================================================================================*/
unsigned int DmaBuffer = 0;
void __attribute__((__interrupt__)) _DMA0Interrupt(void)
{
if(DmaBuffer==0) {
ProcessADCSamples(&BufferA[4][0]);
ProcessADCSamples(&BufferA[5][0]);
} else {
ProcessADCSamples(&BufferB[4][0]);
ProcessADCSamples(&BufferB[5][0]);
}
DmaBuffer ^= 1;
tglPin(); // Toggle PORTA, BIT0
IFS0bits.DMA0IF = 0;//Clear the DMA0 Interrupt Flag
}
void ProcessADCSamples(int * AdcBuffer)
{
/* Do something with ADC Samples */
}