# How to use ATTiny PB5 RESET pin as GPIO

I'm trying to use the reset pin as GPIO.

My schematic is this:

So I wrote a very simple code to make that led blink. This is my code:

#define F_CPU 8000000L

#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
DDRB = 0xFF;
PORTB = 0;

while(1)
{
PORTB = 0b00100000;
_delay_ms(600);
PORTB = 0b00000000;
_delay_ms(600);
}

return 0;
}


And after this, I disabled the reset enabling the RSTDISBL fuse. I just programmed the High fuse to: 0xFE

But the led does not blink.

What am I doing wrong?

• Please provide all pertinent information. What are your full fuse settings (high/low/ext)? Which compiler did you use (I presume avr-gcc from avr-libc, but which version)? May 7, 2017 at 18:43
• Also exactly what commands did you use to program the chip? I presume you used avrdude? what programmer did you use? what order did you do the programming (e.g. fuse first then software, or vice versa)? May 7, 2017 at 18:51
• I used avrdude in Atmel Studio 7. Low fuses: 0x6A. First, I flashed the code, then I flashed the fuses. May 7, 2017 at 19:11
• AFAIU, once you set up PB5 as an output, you can no longer reprogram the chip without using a high voltage programmer, because you can no longer reset it. It might be better to use PB5 as an input instead, and use a different pin for your LED. May 7, 2017 at 21:22

If you take a look at the datasheet for the ATtiny13, you'll see that the reset pin can be used as a "weak" I/O line, meaning it can't perform the same as other I/O lines. On page 140, there are graphs showing the current sinking characteristics vs the output voltage; notice how much less the values are than the other I/O lines shown in the prior pages. Are you operating within the specifications?

Other things to check:

1. Have you tried to talk to the chip since to verify that the RESET line is disabled?
2. Do you have verification that your code was actually programmed to the chip? (AVRDUDE output)
3. Are you sure your series resistor value is correct?
4. Are you sure you have your LED in the correct orientation?

As noted in the comments, using the reset line for I/O means the only ways to reprogram your chip are with a bootloader or "High-Voltage Serial Programming" so it isn't something you should do unless you are out of I/O lines and have an alternative means of programming the chip.

Also of note, you have defined F_CPU to be 8MHz, but your low fuse Value of 0x6A implies that the "Clock divide" fuse is enabled, so your CPU frequency is actually 1MHz.

A few final notes:

• It's always a good idea to "decouple" the VCC line with a 0.1uF ceramic capacitor to GND
• You don't need a "return" statement from main in embedded systems. Where would it return to?
• I'd suggest using the pin macros such as _BV(PB5) or (1 << PB5) rather than the explicit 0b0010000 - it compiles to the same thing
• rather than set, delay, clear, delay, just toggle the pin as such:

PORTB ^= _BV(PB5);
_delay_ms(600);

• "... you'll see that the reset pin can be used as a "weak" I/O line, meaning it can't perform the same as other I/O lines ..." - +1, I found this out the hard way (much like the OP). Jul 7, 2017 at 22:09

Reverse the LED. It's not a PIC. Remove the resistor, you don't need it on this pin, and 1K is way too much.
You should expect less than 15mA without the resistor. For anything else use a switching transistor.