i need help i wrote dies small code for a test conversion of my power supply (5V) i try to see it on debugger Mode in AD convert 0;
this function is for the conversion :
AD0CR |=0x00000000;// AD convertion start
while(AD0DR & 0x80000000 )==0; // conversion complet
return ((AD0DR&0x03FF)>>6);
in my main function how schould i write to see the result of the conversion in AD0 convert Window in debugger Mode i wrote this but didn´t function
int main () { adc_init(); unsigned int result; while(1) { result= adc_read; } } the problem are: is my conversion code o.k? is my main function o.k ; so that i can bekomme 1024 (5v) in my AD convert window?
i use LPC2368, ARM7 thx for a helping code or suggestion
Interesting code you have:
The ADC is 10 bit wide. Which is represented by 0x3FF.
You extract 10 bits from AD0DR. Then you directly shift 6 ticks right. Was that really your intention?
yes it was my Intention but after the convertion is done how can i see the result of my conversion or the (1024 for the 5v) in my virtual window
i wrote this but didn´t function:
in my main funtion while(1){
AD0DR=adc_read(); // put the result into chnnel 0 ADoDr;
}
It really was your intention???
Are you aware of the difference between the following two constructs?
return (AD0DR&0x03FF)>>6;
return (AD0DR>>6)&0x03FF;
my intention is to take the result of the conversion and give it out !
what is the difference between :return(AD0DR&0x03FF)>>6; and return(AD0DR>>6)&0x03FF; ??
If you have no other tools available to tell you the difference between the two statements, you could use a pen and paper.
This really is very basic programming skills. That's like talking about math and not understanding the difference between (2+3)*4 or 2+(3*4).
o.k thkx in this case it mean the same
because (AD0DR&0x03FF) choose the right channel(in my case ch 0).... >> shiftihng it to right 6 place of 10 Bit value;
or AD0DR>>6; first shifting and choose the right channel (AD0DR>>6)&0x03FF
can you please have a complet code For an AD- Convert (ad_init(); ad_read(); the main function to managed and view the result of the convertion) it will be so helpfull
Thx Webmaster
i forgot with ARM; LPC23XX
thx
View all questions in Keil forum