Dual connection of SPI pins of a microcontroller

On a PCB, I want to connect the six pins of a microcontroller (MISO, MOSI, SCK, RST, VCC, and GND) to a header. During the programming, of course these pins are occupied by a programmer. But I also want these pins (at least 4 of them) to be available for other use. My question is: What are the considerations for connecting these pins to both ISP header and connecting them to other devices, say a buzzer or LED or something else. I do not want these pins to be used solely for ISP programming. what are the pitfalls and things I should be careful? Thanks

SMDfan

The programmer will be driving MISO, MOSI, and CLK at its normal clock rate. Ground doesn’t matter, VCC will be supplied by your circuit. Reset (unless you have a Tiny) is dedicated and can’t be used for anything else :-).

Considerations:

  1. Keep capacitance low. The AVR programmers support different programming frequencies (down to several kHz), but I wouldn’t have more than 1nF on any of the data lines.

  2. Don’t directly drive any big loads from those pins. More than a few mA I would use an external FET.

  3. Don’t drive loads that will be damaged by being switched on and off quickly or in a different order.

Sometimes, Ive found that having peripherals connected to programming pins /while/ programming has caused problems (most of the time the chip isnt even recognized).

There are two solutions. The easy one is to simply disconnect the peripherals. However sometimes this isnt possible. In that situation (and like Im doing in a programmer Im working on, with the chicken-and-the-egg problem), Id use a bidirectional buffer. Set the DIR pin high to set the buffers in the direction of the chip being programmed. Set the pin back low (with a pulldown or what have you) and the chip works as if the outputs are buffered (imagine that!). A useful quad buffer for this application is the [74HC243](http://www.nxp.com/documents/data_sheet/74HC243.pdf)