Author Topic: PIC18F46K42 xpress EVAL Board - ADC program  (Read 793 times)

0 Members and 1 Guest are viewing this topic.

Offline arulTopic starter

  • Regular Contributor
  • *
  • Posts: 50
  • Country: in
PIC18F46K42 xpress EVAL Board - ADC program
« on: December 01, 2018, 11:33:02 am »
Hi,

  I have a PIC18F46K42 xpress evaluation board. Now I am developing one of the ADC program using MPLAB Xpress PIC18F46K42 evaluation board on MPLAB CLOUD IDE. I make one of the simple circuit for that program using variable power supply, resistor. I am varying the power source, but that ADC result register value does not change, only shown 0x00 (i got that value 0x00, in debug mode). I have attached my code and circuit.

Please let me know, what is going wrong.....


void main()
{
int RH, RL;

ADCON0bits.FM = 1;
ADCON0bits.CS = 1;
ADPCH = 0b00011100;   //RD4 is analog input
TRISDbits.TRISD4 = 1;
ANSELDbits.ADSELD4 = 1;
ADCON0bits.ON = 1;

   while(1)
   {
   ADCON0bits.GO = 1;
   while(ADCON0bits.GO);
   RH = ADRESH;
   RL = ADRESL;
   }
}
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf