EmbDev.net

Forum: ARM programming with GCC/GNU tools LPC2148 and Sharp 2y0a02 Problem


Author: Dave (Guest)
Posted on:

Rate this post
0 useful
not useful
Hi there,

we're new to microprocessor programming and right now we are trying to 
get an olimex LPC2148 to work with a Sharp Optical Sensor 2y0a02.
But it seems we are too dumb to get the A/D changer to work properly.

We already tested the sensor and it works correctly. We plugged the 
sensor to the p0.30 / AD03 pin
See the code, laugh at us and please tell us where our mind-barrier lies 
:)
#include<targets/lpc2000.h>
#include<stdio.h>


static int erg;
int main(void) {

PINSEL1&=~(1<<29);
PINSEL1|=(1<<28);

AD0CR|=(1<<3); // Kanal 3

AD0CR|=(1<<9);
AD0CR|=(1<<10);

AD0CR|=(1<<16);
AD0CR|=(1<<21);

while(1){
   if(AD0DR3&(1<<31)){
    erg=(short)(AD0DR3>>6);
    debug_printf("%i\n",erg);
  }
}

return(0);
}

Author: Cas (Guest)
Posted on:

Rate this post
0 useful
not useful
I think you have mixed burst mode with polling mode.

Try not setting AD0CR|=(1<<16)

Author: Sharonk868 Sharonk868 (Company: sharonk868) (sharonk868)
Posted on:

Rate this post
0 useful
not useful
Thank you so much for your post.

________________
http://watchmoviesfree.biz

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.