ICSP in live circuit?

I have built a small circuit with an ATTiny45 driving an HC595 which again drives some LEDs. I used an Arduino UNO and Arduino IDE to program the Tiny on a breadboard. All well and good.

Now I want to change the program in the Tiny, so I connected RESET, MOSI, MISO and SCK to the Tiny and tried to upload the new program. This fails with "avrdude: verification error; content mismatch".

The Tiny drives the HC595 using pins 0, 1 and 2, the same pins used for ICSP. If I disconnect the HC595, I can upload the new program just fine.

So here is my question: What do I need in order to make ICSP possible while the Tiny is still "In Circuit"?
Or have I misunderstood the whole idea of "In Circuit Serial Programming"?

Best regards
Stefan

For ICSP to work, the circuit must be powered and the programmer ground must be connected to the MCU ground.
There are limitations on the external loads that can be connected to MISO and MOSI. Consult your programmer's user manual.

Done, done and done!
I'm using an Arduino to program the Tiny, all is connected correctly, as it works when I disconnect the HC595.

The guides I have found using the Arduino as a programmer only shows how to program the Tiny on a breadboard. I get this concept, and I can make it work.

What I do not get is why it does not work when the Tiny is connected to the HC595. I have looked at the datasheet for the HC595, but I am unsure which parameters shows the loads that are relevant for MOSI, MISO and SCK when programming the Tiny.

Post a schematic (not Fritzing) of your wiring diagram including the programmer connections.

That should work, if everything including the HC595 is powered up.

This is my setup.

If I try to program the Tiny as shown, I get the "avrdude: verification error; content mismatch" error.

If I disconnect the three wires between the Tiny and the HC595, the Tiny programs fine.

Actually, the Tiny programs fine if I disconnect the LEDs.

I understand how the LEDs could be a problem if they were connected directly to the Tiny SPI pins and thus affecting MOSI, MISO and SCK when programming.

But in this case the current to the LEDs come directly from the 5V pin on the Arduino (via the HC595) and should not affect the SPI?

I then tried powering the circuit via a CR2032 battery (removing the 5V connection from the Arduino, but keeping a common ground). This also throws the avrdude arror regardless if the LEDs are connected or not. If I power the circuit from the Arduino's 3.3V pin, the Tiny programs fine if the LEDs are disconnected.

I seem to miss some basic knowledge about SPI to make this work.
Any ideas what I should look into?

Ah, I have to learn to remember those decoupling caps!
A 100nF on the ICs did the trick :wink: