ICSP and SPI

I've got a project up and running, which (with bit of help from the forum :slight_smile: ) works beyond brilliant. However, it's one huge mass of cables on the breadboard. Two devices are being run by SPI, using pins 13 to 11, with 10 and 9 as SS. After reading up on SPI, I've found that the same terms apply to the ICSP headers.

Looking at the below picture, it does seem that these headers have very specific uses, and thus cannot be used to relocate cables to:

I'm wondering if this is correct. In other words, if the MISO MOSI and CLK pins in (one of) the ICSP header(s) aren't simply 'clones', of a sort, of pins 13 to 11, or can be used for a SPI-interface.

My reason behind this is, that I've got a cable which seems to fit perfectly in this header, which would then save a lot of little wires.

1 Like

I'm wondering if this is correct. In other words, if the MISO MOSI and CLK pins in (one of) the ICSP header(s) aren't simply 'clones', of a sort, of pins 13 to 11, or can be used for a SPI-interface.

Not only can you use it, but you should. It is the "compatibility patch" for the Uno, Mega, and Leonardo. The newer shields do not use D11-D13. They all use that back ICSP connector now.

So I can simply connect this cable, and keep the pin numbers the same (as in; these are clones of the SPI pins in a standard configuration)?
Or do I need to tell the SPI library to use the 'standard' ISCP header? And would that 'free up' pins 11 to 13?

vomov:
So I can simply connect this cable, and keep the pin numbers the same (as in; these are clones of the SPI pins in a standard configuration)?
Or do I need to tell the SPI library to use the 'standard' ISCP header? And would that 'free up' pins 11 to 13?

You do not need to tell the SPI library anything. The SPI data lines are duplicated on the ICSP and the digital pins for each device except the Leonardo. It has the SPI lines only on the ICSP pins.

You must check the pin numbers on that ICSP connector carefully to insure you have the correct pins connected. Connecting two OUTPUT pins together can cause damage, especially if one is HIGH, and the other LOW.

So pins 11-13 won't be freed up when using the ICSP header. It would follow that when I'm using the ICSP header in a sketch, and for example declare pin 11 to be OUPUT, I will break SPI functionality. I think I get it.

And... do I assume correctly that the rightmost header is the one I use, since the other one states that it is for USB?

D11-D13 will be freed up only on the Mega and Leonardo. The Uno still has the SPI data lines mirrored on D11-D13, so if you use the SPI, you can't use those pins on an Uno.

And I use the rightmost header?

vomov:
And I use the rightmost header?

Yes. The one in the pic marked with "(1) MISO".

I've replaced the six little wires with one cable going to the header, placed some tiny cables in the breadboard to make the connections, tested it without changing the sketch, and it works exactly as before. Thanks for your help! :slight_smile: