Im working ADC in PIC24FJ64GA002 microcontroller using proteus simulation. I've a doubt regards AD port configuration register. I've connected a potentiometer in AN12 pin and channel was selected. The problem is even i comment the below analog/digital mode selection config bit code, its working. I can able to get ADC value.

AD1PCFGbits.PCFG12 = 0;

Is not necessary to mention the analog or digital mode for the corresponding pins?


 void InitADC(void)
// *******************************
// 1. Configure the A/D module
// *******************************
// a) Select port pins as analog inputs(AD1PCFG<15:0>)
AD1PCFGbits.PCFG0  = 1; //PCFG(12-0) 1:Digital mode, 0:Analog mode
AD1PCFGbits.PCFG1  = 1; 
AD1PCFGbits.PCFG2  = 1; 
AD1PCFGbits.PCFG3  = 1; 
AD1PCFGbits.PCFG4  = 1;
AD1PCFGbits.PCFG5  = 1; 
AD1PCFGbits.PCFG9  = 1;
AD1PCFGbits.PCFG10 = 1; 
AD1PCFGbits.PCFG11 = 1; 
AD1PCFGbits.PCFG12 = 1; <== **here i set 1**.
AD1PCFGbits.PCFG15 = 1;

enter image description here


  • \$\begingroup\$ "I can able to get ADC value" - if you are able to get the value, what is the question. Maybe you meant to say "I am unable"? \$\endgroup\$
    – Andy aka
    Aug 13, 2015 at 13:27
  • \$\begingroup\$ Hi @Andyaka Me too can able to get the value. My question is according to the datasheet PCFG bit is to setting analog or digital mode. Since i use potentiometer i set PCFG12 bit as 0 for analog, its working it make sense. strange is even its working when i didnt specify the analog mode in PCFG12 bit and also its working when i set digital mode. Sorry for the poor english. \$\endgroup\$
    – user6161
    Aug 13, 2015 at 13:39

1 Answer 1


In most PIC micros, analog mode for a pin is turned on at power-on, i.e., you don't need to do anything to use a pin as analog input (given it is capable of it). Set PCFG to 1 and ADC will stop reading your pot.

  • \$\begingroup\$ Thanks for the reply. Ok.But i set PCFG to 1, ADC is still reading. Let me post the code and screenshot in my main post. \$\endgroup\$
    – user6161
    Aug 13, 2015 at 14:07
  • \$\begingroup\$ I was talking about physical micro. I'm not familiar with the simulator you're using. \$\endgroup\$ Aug 13, 2015 at 15:02
  • \$\begingroup\$ oh ok. Waiting for physical micro. I will test it and let you know. Thanks Mazurov. \$\endgroup\$
    – user6161
    Aug 13, 2015 at 16:47

Your Answer

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

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