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
  • Hi, I am sorry I couldn't check your reply as I didn't receive any email which I usually get when there is a reply to my post. I never came across SFR page registers. I have programmed the ADC using the instructions from "8051 Siemens" book. I guess the code works fine as it runs well when tested with simulator. I think that I am missing something on hardware side to make the port pins to act as analog port pins. The microcontroller am using is Infineon-c504L. Target board is a microMODUL-8051 SBC from Phytec.
    Thank you
    Ramya

Reply
  • Hi, I am sorry I couldn't check your reply as I didn't receive any email which I usually get when there is a reply to my post. I never came across SFR page registers. I have programmed the ADC using the instructions from "8051 Siemens" book. I guess the code works fine as it runs well when tested with simulator. I think that I am missing something on hardware side to make the port pins to act as analog port pins. The microcontroller am using is Infineon-c504L. Target board is a microMODUL-8051 SBC from Phytec.
    Thank you
    Ramya

Children