0

I am using the Arduino IDE as an ISP programmer to program my ATtiny44 IC. Unfortunately, I ran out of pins, so I want to use the reset pin as I/O. I read several articles online that says it is possible and even the datasheet says so.

enter image description here

I have a high voltage programmer as well. I wrote the code in the Arduino IDE and then used its hex file to program it using the high voltage programmer (TNM PROGRAMMER).

enter image description here

After I program, the IC stops working.

////////////////////////////////////EDIT/////////////////////////////////////

const int led = 0;
const int reset_led = 11; //physical pin 4 on attiny

// the setup function runs once when you press reset or power the board
void setup() {
    // initialize digital pin LED_BUILTIN as an output.
    pinMode(led, OUTPUT);
    pinMode(reset_led, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
    digitalWrite(reset_led, HIGH);  // turn the LED on (HIGH is the voltage level)
    digitalWrite (led, HIGH);
    delay(1000);                    // wait for a second
    digitalWrite(reset_led, LOW);   // turn the LED off by making the voltage LOW
    digitalWrite(led, LOW);         // turn the LED off by making the voltage LOW
    delay(1000);                    // wait for a second
}

New fuse bit setup:

enter image description here

////////////////////////EDIT 2 /////////////////////////////////////////

enter image description here

Now, the led on reset has turned off completely while the another still blinks. Powering my attiny44 with 5v.Code is same as before

////////////////////////////////EDIT 3////////////////////////////////////

#include <avr/io.h>
const int led = 0;
#define ledd PB3
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(led, OUTPUT);
  
DDRB |= (uint8_t)(1<<PB3);
pinMode (ledd, OUTPUT);

}

// the loop function runs over and over again forever
void loop() {

PORTB |= (uint8_t)(1<< PB3);
 
 digitalWrite (led, HIGH);
  digitalWrite (ledd, HIGH);

 delay(1000);                       // wait for a second
 
PORTB &= ~((uint8_t)(1 << PB3)); // set PB3 to "low"
 
 digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
 delay(1000);                       // wait for a second
}

This code worked miraculously for me, Thanks to @thebusybee.

/////////////////////////////EDIT 3/////////////////////////////////////////

The PB3 pin is pin11 in arduino.

enter image description here

18
  • 1
    It sounds like you found the answer to what you're actually asking. "After i program ( the ic stops working)." The chip executes code irrespective of whether or not the reset function is enabled. So, your problem is elsewhere. I would look at whether or not I was staying out of the brownout detection and pay attention to what I was actually using as indication to determine that it "stops working" and maybe that will lead to a different question.
    – timemage
    Feb 15, 2023 at 12:54
  • 1
    What do you mean by "stops working"? Feb 15, 2023 at 13:09
  • If you are powering it by 3.6V (4.2V fully charged) battery, then with 4.3V BOD level it'll be held in reset state all the time (it might work a little if the battery is fully charged and you are lucky to have threshold deviation closer to 4V)
    – KIIV
    Feb 15, 2023 at 20:28
  • You could enable CKOUT fuse to have PB2 indicate that the clock is going. You appear to be forcing the watchdog timer to run and we're not seeing your code, which leads back to the question of how you're determining "stops working."
    – timemage
    Feb 15, 2023 at 21:40
  • @timemage The reset pin is PB3. I have connected one led to the reset pin in order to indicate if it is working Feb 16, 2023 at 4:10

1 Answer 1

1

The data sheet gives insights:

Chapter 1.1.4 states:

The reset pin can also be used as a (weak) I/O pin.

"Weak" means here, that the output function cannot deliver as much current as the other outputs, according to figures 21-24 to 21-27 beginning at page 198 roughly 2 to 3 mA. This is commonly not enough for LEDs, except you use a high-efficiency LED.

And on page 66 is this relevant table (I cut the irrelevant column for PB2):

Table 10-8. Overriding Signals for Alternate Functions in PB[3:2]

Signal Name PB3/RESET/dW/PCINT11
PUOE RSTDISBL(1) + DEBUGWIRE_ENABLE(2)
PUOV 1
DDOE RSTDISBL(1) + DEBUGWIRE_ENABLE(2)
DDOV DEBUGWIRE_ENABLE(2) • debugWire Transmit
PVOE RSTDISBL(1) + DEBUGWIRE_ENABLE(2)
PVOV 0
PTOE 0
DIEOE RSTDISBL(1) + DEBUGWIRE_ENABLE(2) + PCINT11 • PCIE1
DIEOV DEBUGWIRE_ENABLE(2) + (RSTDISBL(1) • PCINT11 • PCIE1)
DI dW/PCINT11 Input
AIO

Note:

  1. RSTDISBL is 1 when the Fuse is “0” (Programmed).
  2. DebugWIRE is enabled when DWEN Fuse is programmed and Lock bits are unprogrammed.

Since you have DebugWIRE enabled, this seems to be the cause. The alternate function RESET is still active.

Please be aware that according to note 1 below table 19-4 on page 160:

After programming the RSTDISBL fuse, high-voltage serial programming must be used to change fuses and allow further programming.

This means that your circuit at PB3 needs to withstand the high voltage, and that the voltage source needs to provide enough current, which the circuit additionally draws at the high voltage.


Now to your code.

You use the pin number "0" and hope to have PB3. Well, according to this shamelessly linked pinout this is not correct:

Arduino pinout ATtiny44

Pin "0" is PA0.

PB3 has no number assigned.

Your next step could be to look up the sources of the Arduino library and check, if PB3 has a number assigned at all. I'm afraid this is not the case. If you're lucky and it has, use it. You will want to tell us about your finding then.

You can directly access the data direction control register and the port register. Grab your data sheet and other documentation, read, and implement.

This is untested:

// in setup():
    DDRB |= (uint8_t)(1U << 3);

// in loop():
    PORTB |= (uint8_t)(1U << 3);    // set PB3 to "high"
    PORTB &= ~((uint8_t)(1U << 3)); // set PB3 to "low"
24
  • Yes, i read it and is disabled it but it still did not work for me. After i make debugWire disable the reset led goes full off. Feb 16, 2023 at 8:06
  • Well, that's a good sign, because now the pin became an output and went "low" (erm, how did you connect the LED?) or at least switched off the pull-up. Does the other LED still blink? -- BTW, your title says 44A but the prose 44. What exactly is it? (Correct your question.) Feb 16, 2023 at 8:11
  • Oh that's a relief to know! Okay, so i have connected +ive of led directly to reset pin and -ive directly goes to GND of IC. Yes, with the new setup the other led still blinks. Feb 16, 2023 at 8:18
  • Please add what you tried now to your question, and post the current fuses. If you changed the sketch, please add it, too. Feb 16, 2023 at 8:22
  • 1
    See my edit, your code is wrong. I assumed you checked that already. Just a hint: don't program "by random", development is more science than art. Feb 16, 2023 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.