EmbDev.net

Forum: ARM programming with GCC/GNU tools LPC2148 ADC not working properly


von Siddharth S. (Company: Robogenesis) (siddharth_shaarma)


Attached files:

Rate this post
useful
not useful
I am noobie in Arm programming and  LPC2148 i have a written a program 
for ADC to glow Leds. it is not working properly. i am not able to see 
the LED glowing.

 i think there is some confusion for operating frequency but i am not 
sure

Can anyone suggest anything.?
come on guys. Show some attachment to the new guy.

this is my code:

#include<lpc214x.h>

static unsigned short ADC_Read(unsigned char ch)
{
  unsigned int i;
  AD0CR=0x00200300 | ch;
  AD0CR|=0x01000000;
  do
  {
    i=AD0DR0;
  }
  while((i & 0x80000000)==0);
  return (i >> 6) & 0x03ff;
}


int main()
{
unsigned int z;

IO1DIR=0xffffffff;

       while(1)
        {
         z=ADC_Read(1);
         if (z<500)
         IOPIN1=0x000;
         else if (z>500)
         IOPIN1=0xff;
        }

/*unsigned int z=500;
PINSEL0=0x00000f00;
PINSEL1=0x05500000;
PINSEL2=0x00000000;
IO1DIR=0xffffffff;
AD0CR= 0x00200301;

  while(1)
    {
 while((AD0GDR&0x80000000)==0x00);
  z=(AD0GDR&0x00000ffc0);
  z=(z>>6);
  IOPIN1=0xfffffff;
  delay(z);
  IOPIN1=  0x0000000;
  delay(z);
    }
  */
  }

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.