midijl
Newbie level 1
Hi, I'm trying to configure a single Channel ADC on a DSPIC33FJ128GP202, 12 bits, on AN1 , no DMA , no sequencing , here is my init code , the issue I have here is that I'm well getting the AD1IF auto interrupt but ADC1BUF0 is always #0000 , if anybody can help, thks, my PIC is running at 80 Mhz , 40 Mips and I have other modules and software running well except this ADC module ,AVDD and AVSS are well connected , TEMP is W0 :
; Init ADC
mov #0X0001,TEMP
mov TEMP,AD1CHS0 ; channel Input is AN1
bset AD1CON1,#ASAM ; SAMP bit auto set
bset AD1CON1,#SSRC0 ; Auto sampling and convert
bset AD1CON1,#SSRC1
bset AD1CON1,#SSRC2
bset AD1CON1,#AD12B ; Select 12 Bits , 1 Chnl ADC Operation
clr AD1CON2 ; No channel scan for CH0+, Use MUX A, SMPI = 1 per interrupt, Vref = AVdd/AVss
clr AD1CON4
clr AD1CSSL
mov #0X031F,TEMP ; auto sample time and conversion clock select
mov TEMP,AD1CON3
bclr IFS0,#AD1IF ; reset ADCInterrupt flag
bset AD1CON1,#ADON ; Turn ON ADC module
; Init ADC
mov #0X0001,TEMP
mov TEMP,AD1CHS0 ; channel Input is AN1
bset AD1CON1,#ASAM ; SAMP bit auto set
bset AD1CON1,#SSRC0 ; Auto sampling and convert
bset AD1CON1,#SSRC1
bset AD1CON1,#SSRC2
bset AD1CON1,#AD12B ; Select 12 Bits , 1 Chnl ADC Operation
clr AD1CON2 ; No channel scan for CH0+, Use MUX A, SMPI = 1 per interrupt, Vref = AVdd/AVss
clr AD1CON4
clr AD1CSSL
mov #0X031F,TEMP ; auto sample time and conversion clock select
mov TEMP,AD1CON3
bclr IFS0,#AD1IF ; reset ADCInterrupt flag
bset AD1CON1,#ADON ; Turn ON ADC module