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 );
}

Parents
  • I am not using Monitor-51 for debugging. I have used simulator to test it on PC. After downloading the code to SBC, I have run the application in which this SBC is a part of. The application has a temperature sensor which sends out voltages between 0-5V. These voltages are applied to 8051 at pin P3.2 (analog port pin). The resultant digital value is send out through TXD pin and displayed on an LCD. I am testing the application at room temperature but the values displayed are extreme.
    Any help is highly appreciated.
    Thanks in advance
    Ramya

Reply
  • I am not using Monitor-51 for debugging. I have used simulator to test it on PC. After downloading the code to SBC, I have run the application in which this SBC is a part of. The application has a temperature sensor which sends out voltages between 0-5V. These voltages are applied to 8051 at pin P3.2 (analog port pin). The resultant digital value is send out through TXD pin and displayed on an LCD. I am testing the application at room temperature but the values displayed are extreme.
    Any help is highly appreciated.
    Thanks in advance
    Ramya

Children
No data