Society of Robots - Robot Forum
Software => Software => Topic started by: superchiku on March 18, 2008, 09:12:42 AM
-
can anyone tell me how i read all the 10 bits of the adc resolution in an atmega16 and store them in a variable??
-
Compiler???
But in general words you just need a variable big enough...
A Word variable is nice here (16 bit variable)
Cheers...
If you are using BASCOM-AVR I can help you...
-
I usually work with pics but see if this applies:
There are 2 byte registers containing the 10 bit reading called ADRESH and ADRESL, they can set to either left or right justify.
All I do is to:
Int reading = 0;
//do adc conversion
reading = ADRESL;
reading += (ADRESH*256);
Something like this, so the register that contains the appropriate 9th and 10th bit gets multiplied by 256. The total value is stored in the int variable reading.
-
nice answer yes the atmega system is same as pic only names are different and the compiler iam using is winavr
-
its pretty much clear in the datasheet, check the ones on the atmel website , they provide examples
-
yes done that thanks...