I am trying to get an analog input working on my microcontroller. I am using the PIC 24FJ128GA204. The problem is that a specific input is not working, while other do work.

I want pin 26, AN9/C3INA/RP15/T3CK/T2CK/CTED6/CN11/RB15, to be the input. Other analog inputs seem to be working fine, but when I configure the input pin to be AN9 the results seem to be floating, even if I ground the input. The samples I get: 3987, 3987, 3988, 3989, 3989, 3987, etc. Below is the code I am using:

void initAD(){
//Pin used for ADC is pin 26 = RB15 = AN9

TRISBbits.TRISB15 = 1; //RB15 is input
ANSBbits.ANSB15 = 1; //analog mode

AD1CON1bits.MODE12 = 1; //set 12 bit mode operation
AD1CON1bits.SSRC = 0b0111; //auto-convert
AD1CON1bits.ASAM = 1; //SAMP bit is auto-set

AD1CON2 = 0; //AD1CON2 all 0
AD1CON2bits.PVCFG = 0b00; //00 = Vss, 01 = External VREF+
AD1CON2bits.NVCFG0 = 0; //AVSS

AD1CON3bits.SAMC = 0b11111; //Auto sample time = 31 TAD
AD1CON3bits.ADCS = 0b00000101; //AD conversion clock 5*Tcy = TAD

AD1CHSbits.CH0NA = 0; //negative is VREF-/AVSS
AD1CHSbits.CH0SA = 0b01001; //channel A AN9

AD1CHSbits.CH0NB = 0; //negative is VREF-/AVSS
AD1CHSbits.CH0SB = 0b01001; //channel B AN9

AD1CSSL = 0;            //No scanned inputs
AD1CON1bits.ADON = 1;   //enable AD module


uint16_t ADread(){


Thanks for reading. If you have any suggestions, that would be great.

  • \$\begingroup\$ Did you figure this out? I have the exact same problem - same part number, same input pin. All other pins are fine. \$\endgroup\$
    – Ross S
    May 8, 2015 at 18:24
  • 1
    \$\begingroup\$ Its the thing in the errata sheet, described below: AN9 is simply not available on the 28 pin devices. Had the same problem. If it wasn't for that thread, I would have never found this one, especially so, because 99.9% of the time if something is not working it is your fault not reading the datasheet correctly. I would have kept on searching this for days. Thanks for posting the question and thanks for hinting at the errata sheet. \$\endgroup\$
    – jjstcool
    Oct 25, 2017 at 13:32

4 Answers 4


I had the same problem..

PIC24FJ128GA204 Family Silicon Errata and Data Sheet Clarification

AN9 has been removed from all 28-Pin diagrams and tables. This analog channel is unimplemented in 28-pin devices.

But datasheet is not repaired..

  • \$\begingroup\$ "The Devil is in the Details" I always say... \$\endgroup\$
    – rdtsc
    Oct 16, 2015 at 14:05
  • \$\begingroup\$ I remember stumbling upon a PIC micro that had one of the ADC channels physically not connected to the multiplexer. Errata is always worth taking a look at ;) \$\endgroup\$
    – Ashton H.
    Oct 16, 2015 at 16:13

The code looks correct to me. Check the rest of your code to see if you accidentally assigned some digital peripheral output to this channel. Better yet, instead of posting code fragments write a short sketch demonstrating this particular issue only, i.e., conf.bits plus main with AD init and poll and nothing else. It would also be helpful to know how you test.


Do you use DMA?

You are reading ADCBUF0 all the time.

I think some dsPICs have dedicated ADCBUFx for every analog pin, others just use ADCBUF0 for every conversion.

You also need to configure other stuff...

Tell adc to scan channels:


Tell adc to convert for instance CH0:


Select which channels to scan:


The analog channels and if you have two ADCs on board both configuration must be identical for registers:


The dsPIC ADC can be a pain to configure.


The analog Input AN9 does not exist on this device

  • 2
    \$\begingroup\$ What exactly does this add, that the other answers did not already address? \$\endgroup\$
    – Lundin
    Jan 8, 2018 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.