12

My usual method of reprogramming AVRs (so-far limited to ATtiny13 and ATtiny2313) is to disconnect the chip from the host circuit, plug it into another breadboard with all of the ICSP hookups in place, program, then replace. However, I keep hearing that one can program the chip in place (which is, I understand, the whole point of ICSP).

Are there any special hardware considerations one has to take into account before programming the chip in situ? For instance, I worry that the ICSP process may damage circuit components connected to the same AVR pins which are used for ICSP. Does one occasionally need to add diodes or some other kind of buffering to protect these components?

I know this question sounds kind of vague, and I guess it is - but I've not provided details of my particular circuit because I'm interested in more general rules of thumb. I.e. does one never have to worry about this, or does the answer really depend on the particular circuit the MCU is a part of?

tyblu
  • 8,167
  • 6
  • 40
  • 70
Tim
  • 447
  • 1
  • 6
  • 14

3 Answers3

15

I've used ISP for just about every AVR board I've done; it's nothing to be afraid of. The AVR ISP mkII manual gives a pretty good summary of the limitations you need to look out for in the "Target Interface" section. Basically, if you run the MISO/MOSI/SCK pins directly to the programmer and have about 820 ohms between them and the rest of the circuit (and aren't doing anything funky with the reset pin) you're okay. I wouldn't worry about the ISP damaging other components; it's not a high voltage programmer. The signals all run at 5V, so if it can damage an external component, so can your microcontroller.

If you're really stuck with a board that doesn't permit ISP programming, I'd at least try to use a ZIF socket for your programming board. They're pricey, but it will greatly improve your quality of life.

phooky
  • 1,008
  • 7
  • 12
  • Thanks for the link - that's exactly what I'm after. I'm not actually using a real AVR ISP - just an appropriately programmed arduino. (!) I'm replacing this with a Bus Pirate in a few days, so throwing together a board with ZIF sockets is definitely something I'm planning to do. My current procedure is extremely ugly! – Tim Oct 30 '10 at 02:23
1

Use a jumper or a switch so that you can physically disconnect the ICSP header. This way you can share the pins with other functions without worrying, and without having to fiddle with your other components.

This seems like the most obvious and safest solution, and it's what I use.

(My first answer was deleted, so I have tried to add more detail).

Ali Afshar
  • 123
  • 6
  • How would that work? Then, when the switch/jumper is connected, the pins will still be connected to the rest of the circuit. – eeze Mar 02 '19 at 01:12
-1

Unfortunately, you cannot do in circuit programming for your AVR's if the pins are shared by other functions, for example lighting LEDs. While it might work, it's not guaranteed as it may cause the programmer's or µC's outputs to drop too low for it to work.

One other alternative is to order your chips pre-programmed. I know Microchip offers this for some of their chips, but I'm not sure about Atmel.

Thomas O
  • 31,546
  • 57
  • 182
  • 320
  • Oh well, I suspected this. I'll just have to keep doing things my slow and clunky way, I guess. (Oh, and no chance getting Atmel to do pre-programming for me, I'm just a lowly hobbyist. :-) ) – Tim Oct 30 '10 at 01:31
  • Microchip charges ~$40 "setup fee." Again, unsure about Atmel. If you're ordering in the 10-100 range, it's probably worth it. – Thomas O Oct 30 '10 at 01:33
  • 3
    I've programmed plenty of boards with other loads on the SPI pins, particularly LEDs, with no problems at all. Just be careful not to have anything else drive the signals. This means, for instance, if you have an SPI device connected, give it a pull up resistor or similar to keep that too in reset or unselected. – Yann Vernier Oct 30 '10 at 07:54