silverwolfman
Junior Member level 1
- Joined
- Feb 22, 2013
- Messages
- 16
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,408
MPLAB X16, dsPIC33FJ
Hi guys,
Its my first time tried to use the ADC module and it really gives me some hard time, I've tried to use AN1 & AN2 as the analog input, 12bit accuracy, using scan method and only opened muxA, I saw the value change in ADC1BUF0(its fluctuated because its switching between AN1 and AN2), the device I am using is with DMA, I have 2 questions:
1.what should I do to read out the these two value sperately? I am not quite familiar with the DMA. Can I have some examples how to setup and use the DMA for ADC?
2.another question is, if I have to match the two Analog input to DMA, does that mean the device with DMA is slower? In stead of reading directly from register(ADC1BUF0,ADC1BUF1....in device without DMA) I have to write the value into memory first and then read back?
Thanks ahead.
Hi guys,
Its my first time tried to use the ADC module and it really gives me some hard time, I've tried to use AN1 & AN2 as the analog input, 12bit accuracy, using scan method and only opened muxA, I saw the value change in ADC1BUF0(its fluctuated because its switching between AN1 and AN2), the device I am using is with DMA, I have 2 questions:
1.what should I do to read out the these two value sperately? I am not quite familiar with the DMA. Can I have some examples how to setup and use the DMA for ADC?
2.another question is, if I have to match the two Analog input to DMA, does that mean the device with DMA is slower? In stead of reading directly from register(ADC1BUF0,ADC1BUF1....in device without DMA) I have to write the value into memory first and then read back?
Thanks ahead.
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 /********* Initialize ADC **************************************/ void InitADC(void){ TRISB|=0x0001; TRISA|=0x0003; AD1PCFGL=0xFFF8; //AN0=external reference, AN1, AN2 AD1CON1bits.ADON=0; //turn off the adc AD1CON1bits.AD12B=1; //12bit conversion CH0 AD1CON1bits.ASAM=1; //Sampling begins after conversion auto sampling AD1CON1bits.SSRC=7; //Automatic sampling the data AD1CSSL=0x0006; //Sample scan channels AN1& AN2 AD1CON1bits.FORM=1; //signed data AD1CON2bits.CSCNA=1; //select scan auto sampling AD1CON2bits.SMPI=0x0001;//select 2 conversion after sampling AD1CON2bits.VCFG=0; //select reference source AD1CON2bits.ALTS=0; //Just use the scan channel AD1CON3bits.ADRC=0; //system clock as sampling AD1CON3bits.SAMC=0x1; //sample clock AD1CON3bits.ADCS=63; //ADC clock frequency=100kHz AD1CHS0=0x0101; //scan AN1 and AN2 using MuxA AD1CON1bits.ADON=1; //enable ADC }
Last edited: