ADC for 2 analogue inputs

Status
Not open for further replies.

flemmard

New Member
Hi all,
I need to read 2 different analogue inputs to PIC16f877.These are my macros for those inputs.Can anyone please check whether my ADCON0 values are correct ?Anyother simple way to take 2 different analogue inputs?
thanks

Code:
unsigned char read()
{
       
         ADCON0 = 0b11000101;  //channel 1
         ADCON1 = 0x00;
         
         ADGO=1;
         
                  while(ADGO) continue;
                  
  

         return ADRESH;
}

unsigned char read1()
{
         
         ADCON0 = 0b11001101; // channel 2
         ADCON1 = 0x00;
         
         ADGO=1;
         
                  while(ADGO) continue;
                  
  

         return ADRESH;
}
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…