Hi everyone,
I just read through the source code of the `analogRead` function in `cores/arduino/wiring_analog.c` and noticed that the way it is now the internal channels of the ADC, i.e. the internal temperature sensor, the bandgap reference and the GND channel are not accessible.
These channels have channel numbers above 7 and therefore require the bit MUX3 set in the ADMUX register to be selected. However, the MUX* bits in ADMUX are written through a 0x07 mask, wich makes it impossible for MUX3 to be set. Using a mask of 0x0f would make these channels accessible.
I'm not sure if this behavior ist intentional, since the function is written to allow a specification of the ADC channel rather than the pin name. Besides these three channels are handy and basically come for free.
With additional pin name constants like "ATEMP" or "ABANDGAP" set to the
respective channel number, there would be an easy way to access these channels with minimal changes to the core code.
Regards,
Florian Ehmann