EmbDev.net

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


Author: Siddharth Sharma (Company: Robogenesis) (siddharth_shaarma)
Posted on:
Attached files:

Rate this post
0 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);
    }
  */
  }

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.