From: Dave H. <dhy...@gm...> - 2008-07-03 14:48:36
|
Hi Tracy, > I used to use the getADC command using I2C, however, I recently changed to > using a2d_10.c. The weird thing is they give me different results. As far as > I can see, both make use of ADCH and ADCL so surely they must give the same > readings? What is the difference and would there be any reason to use the > one or the other? Also how can I make a2d_10.c give me the same readings as > getADC? What is the getADC command that you're referring to? Some A/D functions return an 8-bit value, and some return a 10-bit value. The ADLAR bit determines if the 10 bit result is in the leftmost 10 bits or the rightmost 10 bits of the 16-bit ADC register. Normally, when reading 8-bit values, you would set ADLAR=1 and just use ADCH which will return the most significant 8-bits of the 10-bit result. Are the REFS0 and REFS1 bits set the same in both cases? Obviously changing the reference voltage used will change the result. -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/ |