atmega8--ADC
Thu Mar 21 2013, 05:14 pm
My code for adc work properly in protyus...But not run properly on actual hardware...Its give high state to PORTB and PORTD pins(actually it has to show digital data converted by ADC )..Plz look at my code..give me correction
Fri Mar 22 2013, 04:07 am
while (ADCSRA & (0<<ADSC));/
does not look right !
[ Edited Fri Mar 22 2013, 04:12 am ]
Sat Apr 13 2013, 05:16 pm
Actually i am trying to send converted data to port like PORTD=ADCL..... when i apply input to adc channel greater than 3 volt all the LED is going to blink(PORTD=0xff PORTB=0x03;(total 10 led)) which means input voltage is nearer to 4.99 volt....Can u tell me why this happen???.....Also for some voltage like 2.64 volt all LED is go high...
Some other readings that i had taken....input v output v
2.43 2.49
0.31 0.36
0.09 0.15
Some other readings that i had taken....input v output v
2.43 2.49
0.31 0.36
0.09 0.15
Sun Apr 14 2013, 12:49 pm
@vijay.parmar1992
Agreed with ExperimenterUK...
It's while(!(ADCSRA & (1<<ADIF))); // waits till conversion completes
replace the above line in ur code..
Agreed with ExperimenterUK...
It's while(!(ADCSRA & (1<<ADIF))); // waits till conversion completes
replace the above line in ur code..
Sun Apr 14 2013, 07:28 pm
connection that i am using for atmmega 8
vcc=avcc=avref=5v(approximately 5.4v)
gnd=agnd=0(gnd)
using internal 8mhz clcok..
i am not using any capacitor between aref and gnd ??is it require..
vcc=avcc=avref=5v(approximately 5.4v)
gnd=agnd=0(gnd)
using internal 8mhz clcok..
i am not using any capacitor between aref and gnd ??is it require..
Mon Apr 15 2013, 06:10 pm
This is fine.. if you get a non zero value means bit is still set, if its zero then while loop will exit.
capacitor is not mandatory.
while(!(ADCSRA & (1<<ADIF)));
capacitor is not mandatory.
[ Edited Mon Apr 15 2013, 06:11 pm ]
Mon Apr 15 2013, 11:39 pm
I am now usingwhile((ADCSRA & (1<<ADSC))!=0){ };
Is it ok???vijay.parmar1992
It's getting complicated
As I see it...
while((ADCSRA & (1<<ADSC))!=0){ };
Will wait until the ADSC bit goes low.
you could just say
while((ADCSRA & (1<<ADSC))){ };
while(!(ADCSRA & (1<<ADIF)));
I believe will wait until the ADSC bit goes high.
Powered by e107 Forum System