This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Sending analog input to the microcontroller's analog-to-digital converter

Hi,
I am trying to input analog data at port3 analog input pins (p3.2,p3.3,p3.4). When the program is run in the IDE it works fine taking all the analog inputs supplied through A/D converter peripheral window. but when the program is downloaded onto the PHYTEC board it doesn't accept the input applied, but takes some default values. What could be the possible reason? Here are some lines from my code

void main(void)
{
 ADM = 1;        /*continuous conversion mode to perfrom multiple A/D conversions*/
 SYSCON |= 0x10;       /*setting RMAP (bit 4) of SYSCON for accessing the SFRs located in mapped SFR area*/
 P3ANA &= 0xE3;        /*clearing bit location (here P1.0,P1.1,P1.2) makes the port line to operate as analog port */
 SYSCON &= 0xEF;

 for(i=4;i<7;i++)
 readADC(i);
}
unsigned int readADC(unsigned char channel)
{
  ADCON1 &= ~0x0F;                          //Clears Channel for selection
  ADCON1 |= 0x0F & channel;                 //Selects received Channel
  ADDATL |= ~ADDATL;                        //Write to ADDATL starts execution of ADC

  while( BSY);                    //Wait until A to D is complete
  //IADC = 0;
  return( (  ( (unsigned) ADDATH << 8) | ADDATL ) >> 6 );
}

0