halfbridge1974 / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Modify wiring_analog.c to support ADC8 internal temperature sensing on ATMega328 and siblings #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Selecting ADC8 in a sketch results in the ADC0 output being selected due
a bit masking function in line 45 of
\\hardware\cores\arduino\wiring_analog.c

2. Change
ADMUX = (analog_reference << 6) | (pin & 0x07);
to
ADMUX = (analog_reference << 6) | (pin & 0x0f);

3. The original code was correct when AT chips only used ADC channels 0 to
7, but this masks out the new ADC8 internal temperature measurement channel.

What is the expected output? What do you see instead?
ADC8 output is expected; ADC0 output is provided

What version of the Arduino software are you using? V0015
On what operating system?  Windows; but the code is the same in Linux and
no doubt Mac.
Which Arduino board are you using? Diecimilla/BareBones Board.

Please provide any additional information below.
Temperature Sensing is available on ATMega328 (confirmed) and newer
production lots of its siblings (unconfirmed)
Refer to Arduino Forum › Software › Development › Internal Temperature
Measurement ATMega328.

Original issue reported on code.google.com by NeilGMat...@gmail.com on 5 Apr 2009 at 3:12

GoogleCodeExporter commented 9 years ago
I was just about to suggest this enhancement for AtMega168 and found this issue
already logged.

On AtMega168 ADC14 and ADC15, which is the internal bandgap VREF and 0v 
measurements,
the internal bandgap measurement is handy for self measurements of the battery
voltage/VCC without any external components, the internal bandgap can also be 
used as
a temperature sensor.

Original comment by madeino...@gmail.com on 21 May 2009 at 7:10

GoogleCodeExporter commented 9 years ago
Example of how to read battery voltage using this method
http://blog.everythingrobotics.com/2009/06/09/reading-widget-battery-voltage/ 

Original comment by madeino...@gmail.com on 10 Jun 2009 at 3:38

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 15 Jun 2009 at 7:41