LPC2148 and Sharp 2y0a02 Problem

Guest #1603158
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 
:)
1
#include<targets/lpc2000.h>
2
#include<stdio.h>
3

4

5
static int erg;
6
int main(void) {
7

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

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

13
AD0CR|=(1<<9);
14
AD0CR|=(1<<10);
15

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

19
while(1){
20
   if(AD0DR3&(1<<31)){
21
    erg=(short)(AD0DR3>>6);
22
    debug_printf("%i\n",erg);
23
  }
24
}
25

26
return(0);
27
}

Reply

A question of your own? This thread is over 16 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.