High-Voltage Programming to Gain an I/O Pin

On the previous page, we have successfully programmed an ATtiny45 chip using AVR Studio and the STK500 programming tool. There is another variation of programming available that is particularly useful for Atmel tiny AVR chips, which we will now discuss.

Gaining a Pin

The tiny AVR microcontroller chips are great for small projects or modules. Most of these chips have 8 pins. Two pins are used for power (Vcc and GND) and the third pin is used for reset. That leaves five pins, which is usually adequate.

If you don’t need a reset pin in your project, it would be nice to be able to configure it as another digital I/O pin (input/output) or analog input. Unfortunately, the reset pin is needed for programming the chip, even if you don’t need reset in the project itself.

The fine people at Atmel figured out a way to use the pin for both purposes. If the chip and programming board are configured for “high-voltage programming”, then 11.5 V is used instead of ground (0 V) to signal reset. Because microcontroller pins are connected to much lower voltages in projects, the standard 0 V to 5 V signals will not cause a reset, and that pin can be used for input and output.

On the ATtiny45, the reset pin (PB5) can be used for input (digital or analog ADC0), with or without a pull-up resistor, and with or without an interrupt (PCINT5). It can also be used for low/high output, although it isn’t capable of producing as much current as the other pins. So, avoid using it to drive an LED. I’ve made that mistake twice -- confusing me as to why that one LED segment didn’t seem as bright.

Jumper Settings on the STK500 Tool

High-voltage programming the ATtiny45 uses the same setup as shown on the previous pages, with a couple of changes. So, make sure you first set up the board as shown on those pages. Then, attach the shunt to jumper BSEL2.

STK500 BSEL2 jumper for high-voltage programming.

STK500 BSEL2 jumper for high-voltage programming.

Next, disconnect the ISP6PIN ribbon cable from SPROG1. Using the jumper wires included with the STK500 kit, attach them as shown below.

STK500 jumpers for high voltage programming

STK500 jumpers for high-voltage programming.


Setup in AVR Studio

Next, power on the STK500. In AVR Studio, click the Connect button just as you would to program the STK500 normally.

After connecting, on the Main tab, select PP/HVSP (parallel programming / high-voltage serial programming) mode instead of ISP (in-system programming) mode. Press the “Read Signature” button to verify that it is able to communicate with the chip.

Choosing PP/HVSP mode in AVR Studio

Choosing PP/HVSP mode in AVR Studio.

There’s nothing wrong with using this mode even if you decide not to override the reset pin. However, if you now want your program to be able to use the reset pin as I/O, then you need to switch to the Fuses tab.

RSTDISBL checkbox to gain control over reset pin

RSTDISBL checkbox to gain control over reset pin.

Check the RSTDISBL checkbox and click the “Program” button on the bottom of the Fuses tab. The reset pin is now available for your software (firmware) to use as it desires on that particular chip.

Following this technique, I was able to have an ATtiny45 emulate a LM393 comparator chip to replace the brain in Sandwich for the purposes of a long-exposure photograph. The microcontroller proceeded to drive the robot for 12 seconds (producing a comparator output) and then stop to expose an image of the robot’s body in the photo. Some jumper wire, a different circuit, or a custom daughterboard would have been required if I could not override the reset pin, as that pin is normally used in the LM393 pinout

One caveat to setting the RSTDISBLE fuse is that the reset pin is needed for standard ISP programming. So, that chip won’t respond again in ISP mode until you turn off the RSTDISBL fuse in the chip to switch it back to being a reset pin.

This problem caught me off guard with some chips I had programmed a while ago. Years later, when I pulled them from a robot and tried to program the chips, there was no response. They worked in the robot -- so the chips weren’t dead. It took me a while to recall that they I had disabled the reset pin on them.