I'm using the hardware SPI to control a bank of TI TLC5916 constant current drivers. I'll never read from them so I don't need pin 12 (MISO).
All other pin ports are in use with other connections but need one more, so hope I can reuse this one.
Will using pin 12 as an output mess up anything, like the internal SPI library or registers, prevent reprogramming the atmega chip via ICSP, etc?
Thanks in advance.
I believe that if you have
running, the library takes over the pin as an input.
You can use SPI.end();
and turn off SPI, be sure to turn it back on when you want to use it.
Never tried that myself.
Any chance you can set up a shift register to create the chip selects for your bank of parts and free some pinse that way?
Just looking at the code I would say you are OK to use the pin as an output after the call to .begin().
pinMode(MISO, OUTPUT) after .begin() then carry on.
NOTE: You can use .end() but it does not change the pinMode so you still have to do a pinMode(x, OUTPUT).
That conflicts with the data sheet, 8271D–AVR–05/11:
“When the SPI is enabled, the data direction of the MOSI, MISO, SCK, and SS pins is overridden
according to Table 19-1 on page 170.”
You're right, MOSI, SS and SCK are user defined but MISO is set as an input.
All other pin ports are in use with other connections but need one more,
Chris, you should then be able to use MISO as an input, can you rearrange your circuit to free up another pin you have as an input, use MISO for that function and make the freed pin an output.
The only inputs I have are multiple buttons on analog pins (6 buttons, 2 pins). I guess I will try putting all 6 buttons on one analog pin; that will give me another pin I can use for output and let me avoid having to reuse the MISO pin.
Thanks again for your help.