arduino / arduino/ArduinoCore-avr
AnalogRead and the DIDR register
- Dominant language
- C
- Stars
- 1.5k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I was researching the best ADC performance of the ATmega328, and found this reference below:
> Don’t forget to DIDR!
> the DIDR (Data Input Disable Register) disconnects the digital inputs from which ever ADC channels you are using. This is important for 2 reasons. First off, an analog input will be floating all over the place, and causing the digital input to constantly toggle high and low. This creates excessive noise near the ADC, and burns extra power. Secondly, the digital input and associated DIDR switch have a capacitance associated with them which will slow down your input signal if you’re sampling a highly resistive load.
> Unfortunately, Arduino doesn’t do this for you automatically. But it’s as easy as adding the line DIDR0 = 0×01; to your setup() section to use ADC0. If you’re using ADC1 you set bit 1, if ADC2 you set bit 2, and so on.
Would it be possible to embed this register in the pinMode( ) function?
http://www.openmusiclabs.com/learning/digital/atmega-adc/index.html
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the pinMode() implementation and the ATmega328 DIDR register reference linked in the issue. Determine whether pinMode() should control DIDR bits, how ADC channels map to pins, and what behavior and verification would define the change as complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100