# Using AVR reset pin as ADC

I am using an ATTINY13 for a toy application. It simply blinks LEDs in specific patterns. I decided to add a "speed control" using a potentiometer but the only pin I had left is the reset pin.

I've created a voltage divider and padded it with 330 ohm resistors, and things seem to work just fine on a breadboard.

After reading up a bit on using the reset pin for ADC, it seems that some people advise that you cannot program the AVR again. I haven't had this problem, but I am also not doing in-system programming.

The code I am using to enable ADC0 on pin 1 (PB5) is as follows:

DDRB = 0b00001000;


My question is: Why is this working? I would like to know a little bit more before proceeding with PCB manufacture. Is it just dumb luck so far?

I assume because reset never "sees" ground, the micro never resets spontaneously in circuit, but I'm unclear as to how I've managed to use the reset pin for ADC without disabling flash reprogramming.

Note: I currently am using a DIP-8 version of the chip in a socket, which I relocate to a programmer to change parameters. I will switch to a SOIC version for production.

Other: The 6-pin header connects to some Charlieplexed LED's

• you need to clarify what you mean by "but I'm also not doing in-system programming" and how that differs from "flash reprogramming"... – vicatcu Sep 17 '12 at 2:52
• I'm (currently) reprogramming the micro by itself; not in the device that the schematic represents. The final version won't have ISP headers and won't be programmed in-circuit. – JYelton Sep 17 '12 at 2:58

The reset disable fuse does just that - disables the reset function of the associated pin. If you set that fuse, there is no way to reset the device except:

• Power Cycle
• Watchdog Timer Expiration

In-Circuit Serial Programming (also known as ICSP), I believe, relies on resetting the device by way of the Reset pin, and so you will not be able to reprogram the device once this fuse is set using ICSP. There is more than one way to reprogram an AVR though. If the device supports High Voltage Serial or Parallel programming (HVSP or HVPP) that's always an option. Or if you can include a bootloader on the chip (which can be done with an ATtiny85 for example, not sure about the ATtiny13), that can work too.

That being said, the datasheet section 24.3.3 has the following excerpts:

Special combinations of fuse bits will lock the device for further programming effectively turning it into an OTP device. The following combinations of settings/fuse bits will cause this effect:

• 128 kHz internal oscillator (CKSEL[1..0] = 11), shortest start-up time (SUT[1..0] = 00), Debugwire enabled (DWEN = 0) or Reset disabled RSTDISBL = 0.
• 9.6 MHz internal oscillator (CKSEL[1..0] = 10), shortest start-up time (SUT[1..0] = 00), Debugwire enabled (DWEN = 0) or Reset disabled RSTDISBL = 0.
• 4.8 MHz internal oscillator (CKSEL[1..0] = 01), shortest start-up time (SUT[1..0] = 00), Debugwire enabled (DWEN = 0) or Reset disabled RSTDISBL = 0.

If you have no intention of supporting in circuit programming, you can safely program once then set the reset disable fuse and use the pin's alternate function. You do not want to leave the reset function enabled in production unless you don't care about your device resetting in arbitrary ways. Basically if the pin is "low" for a given period of time, it will reset, end of story. Per the datasheet Table 18-4, the range of possible threshold values for external reset to trip is 0.2*Vcc to 0.9*Vcc... you maybe just be getting lucky with devices that are closer to 0.2*Vcc.

• The reset disable fuse I presume is something I would specify with avrdude. I'm not currently doing that. The post I read which caused my concern is here: avrfreaks.net/… – JYelton Sep 17 '12 at 2:59
• yea the reset disable fuse is the potentially crippling thing – vicatcu Sep 17 '12 at 3:02
• So, it appears it is not necessary to disable the reset functionality (by way of this fuse) in order to use the reset pin as ADC. Can I expect reliability from production units without doing this fuse change? – JYelton Sep 17 '12 at 3:12
• @JYelton I wouldn't use the alternate function without disabling the reset function unless I could make a strong argument that either it doesn't matter if it resets inexplicably occasionally or that the conditions that would produce a "low" input (apparently as high as 0.9*Vcc is enough to trip it per the datasheet table 18-4) on the pin can be excluded by design. – vicatcu Sep 17 '12 at 3:26
• Your last edit helped the most, "don't leave the reset function enabled in production" pretty much says what I was missing. Thank you. – JYelton Sep 17 '12 at 3:29