2
\$\begingroup\$

I'm using an ATTiny84 and I have both a switch and a pin header attached to the MOSI pin. I am reading the value of the switch in my program, and I'm using the pin header (along with headers to MISO, RESET, and SCK) to program the chip with my Arduino. I won't be pressing the switch while programming the chip.

When I start programming the chip, will the code already on my ATTiny restart execution, or will it wait until RESET is no longer held low? All I could find in the datasheet is that the pins "are tri-stated when a reset condition becomes active" which I don't understand.

\$\endgroup\$
5
\$\begingroup\$

The ATTiny, and every other IC I'm aware of, can only be programmed while it's held in the reset state. As such, any ICSP device must assert the RESET line for the entire duration of the programming process.

So no, your program will stop running before programming begins, since the programmer will hold reset low.

\$\endgroup\$
3
  • \$\begingroup\$ "and every other IC I'm aware of" It is mostly the smaller ones where that is true. The bit bigger CPUs often have multiple EPROM sectors and the CPU can keep running from a different sector then the one being programmed. Of course no CPU can run when the reset is active. \$\endgroup\$ – Oldfart Apr 20 '20 at 19:06
  • \$\begingroup\$ @Oldfart Fair enough! I've never dealt with any particularly big programmable chips. \$\endgroup\$ – Hearth Apr 20 '20 at 19:09
  • \$\begingroup\$ It shouldn't matter what you do to that switch once the chip is in programming mode. The chip isn't necessarily in the "reset" state. ATTiny84 uses debugWIRE which is a single line debugger/reprogrammer. The data is going over the reset line. So its not in reset per-se but in a programming mode. It will stay that way until the tool ends the session. \$\endgroup\$ – Carl Gilbert Apr 20 '20 at 20:34
2
\$\begingroup\$

The chip halts activity when being programmed. To do something like continuing to execute the current program while being reprogrammed requires a bootloader that uses dual-bank flash so that the original program operates off one bank while the new program is written to the other bank and then switches over (or was running entirely from RAM to begin with to free up the flash for programming).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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