14779
Newbie level 1
- Joined
- Dec 9, 2014
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 13
Hi all,
I am struggling to get the ADC with DMA working on the dsPIC33EP256MC506. I think the issue is in the declaration of the pointer and the size of the buffers. I have looked at the example codes for this but all of the example codes use eds and I believe this controller does not have eds. Any help would be hugely appreciated ( ) as I have been going round in circles with this for a few weeks now.
The initialization of the ADC and DMA is
The interrupt handler is
I am expecting to see the data from AN10, AN0, AN1 and AN2 on data1, data2, data3, and data4 respectively.
Many thanks
I am struggling to get the ADC with DMA working on the dsPIC33EP256MC506. I think the issue is in the declaration of the pointer and the size of the buffers. I have looked at the example codes for this but all of the example codes use eds and I believe this controller does not have eds. Any help would be hugely appreciated ( ) as I have been going round in circles with this for a few weeks now.
The initialization of the ADC and DMA is
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 void Initialise_AD(void) { unsigned int adcBuf[15][1]; AD1CON1=0x0068; AD1CON2=0x0300; AD1CON3=0x0003; AD1CON4=0x0100; AD1CHS123=0x0000; AD1CHS0=0x000A; AD1CSSL=0x0000; AD1CSSH=0x0000; IFS0bits.AD1IF = 0; IEC0bits.AD1IE = 0; AD1CON1bits.ADON = 1; // DMA1 configuration DMA1CON=0x0020; DMA1CNT =3; DMA1PAD=(unsigned int) &ADC1BUF0; DMA1REQ=0x000D; DMA1STAL = __builtin_dmaoffset(adcBuf); DMA1STAH=0x0000; DMA1CONbits.CHEN=1; IFS0bits.DMA1IF = 0; IEC0bits.DMA1IE = 1; }
The interrupt handler is
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 void __attribute__((interrupt,no_auto_psv)) _DMA1Interrupt(void) { _DMA1IF=0; IFS5bits.PWM1IF=0; _SAMP=1; data1=adcBuf[10][1]; data2=adcBuf[0][1]; data3=adcBuf[1][1]; data4=adcBuf[2][1]; }
I am expecting to see the data from AN10, AN0, AN1 and AN2 on data1, data2, data3, and data4 respectively.
Many thanks