10

I am working on an application using ATmega328p atmel microcontroller. I started with the 28 PDIP version, but now I want to use the 32 TQFP, which I noticed has 2 extra inputs after compiling my Altium project.

These inputs are ADC7:6 which "serve as analog inputs to the A/D converter. These pins are powered from the analog supply and serve as 10-bit ADC channels," according to the datasheet.

I have read online that some people have got unknown results when they use the ADC and have floating inputs. What I read they've done is activate pull-down resistors, but I do not see how to configure them (since they do not belong to an I/O port). Also, my application does not even use the A/D converter at all.

What are the best practices? Should I connect an external pull-down resistor? Ignore Altium error?

esal26
  • 123
  • 2
  • 8

2 Answers2

12

A pull-down resistor is good, yes. Not only does it stabilize the inputs and prevent any excess current draw, but it has the hidden benefit that you can use them as a Sample and Hold capacitor purge device. If you read an analogue value from one of these extra inputs in between readings from your other inputs it can make your readings a little more stable as the sample and hold capacitor will be always starting from the same level.

The smaller the resistor the faster the capacitor will discharge, but the higher the outrush current. Something around 470Ω is good. Also protects against the pin ever being configured as an output and driven high.

Majenko
  • 55,955
  • 9
  • 105
  • 187
  • 1
    Wait so if I do 1) Read actual analog value 2)Read pulled-down analog, my actual analog value will be less noisy or something? – Funkyguy Jul 11 '14 at 15:48
  • 1
    It will be less influenced by the readings from other channels. Read channel 1, read spare channel, read channel 2, read spare channel, etc. – Majenko Jul 11 '14 at 15:50
  • Whoaa, thats so sweet! – Funkyguy Jul 11 '14 at 15:50
  • 3
    Extreme example with floating inputs: http://forum.arduino.cc/index.php?topic=182446.0 – Majenko Jul 11 '14 at 16:02
  • I see, although I am unfamiliar with the *sample and hold* cap, it makes sense to fully discharge it and start sampling each time from the same reference point. Great idea. – sherrellbc Jul 11 '14 at 16:06
  • I would normally use a higher value than 470 ohm. If the pin gets configured as an output it would draw 10 mA. My default for these things is 10k - same as a pull-up for a typical digital signal (if I don't need it to be super fast). I do like the idea of measuring zero in order to minimize hysteresis related errors - not sure how real that concern is (depends on the type of capacitor: with only 10 bit accuracy it's unlikely to be an issue, but use a polystyrene capacitor to be safe, not a ceramic. See for instance http://www.analog.com/library/analogdialogue/anniversary/21.html . – Floris Jul 12 '14 at 00:57
8

ADC6 and ADC7 are a special case. They do not have any digital input or output buffers connected to them, so they will not create noise or draw excess current like the other pins on the chip might if not handed appropriately. In other words, you can leave them floating and they shouldn't abnormally affect your design.

They also do not have any internal pull ups or pull downs, so if you do plan to tie them up or down, you will have to do so externally.

Since they can never be outputs, though, there is no additional safety or protection in using a resister versus connecting them directly to VCC or GND. If you are still worried about floating analog inputs, you can simply tie ADC7 to the GND pin adjacent to it, and ADC6 to AVCC (or AREF if you prefer).

The sample and hold capacitor is tiny, so if you do decide to follow the purge recommendation, you can use ADC7 to sample - the capacitor will drain very quickly to ground and you will gain the benefits described.

Adam Davis
  • 20,339
  • 7
  • 59
  • 95
  • I was worried about them having any other functionality like the rest of I/O pins, but you are right, since they are not, I should take the option of leaving them floating. And also, because I am designing the final version of the application and I know the ADC will never be used. – esal26 Jul 12 '14 at 16:31
  • Where did you find that ADC6 and 7 are "special"? I can't verify from the data sheet that those inputs are any different from the others. – Rev Jul 08 '15 at 08:12
  • @Rev1.0 There are many places in the [datasheet](http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf) that show this. Probably the most obvious is the last sentence in `24.9.5` : *"Note that ADC pins ADC7 and ADC6 do not have digital input buffers, and therefore do not require Digital Input Disable bits."* Also note the block diagram in `2.1` which shows ADC[6..7] going straight to the ADC, while the other 6 ADC ports are shared with PORTC, and the pinouts in `Fig 1-1` show ADC6 and ADC7 have no shared functions. – Adam Davis Jul 08 '15 at 12:45
  • Oh my fault, I was looking at the 324/644 data sheet. This is the first Atmel controller where I see this "specialty". – Rev Jul 08 '15 at 13:36