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
The compiler - and the processor - does not agree with you that the two statements would mean the same.
val = 0x12345678; a = (val & 0x3ff) >> 6; b = (val >> 6) & 0xff;
The end result?
a will extract 0x278 and shift 6 steps right. End result 9.
b will shift 6 steps right which gives 0x48d159. Then mask and get 0x159.
Only one of these two expressions will correctly pick up the 10 bits of ADC measurement from the data register and make the measurement available as a number between 0 and 1023.