Quick question, If I only have one spi device, in my case a digital potentiometer , can I set the ss pin on my dp, and just ignore pin 10. No ss pin connection to my arduino ?
Most SPI devices need their SS pin to go low to initiate a data transfer, and high when done. Read your device's data sheet.
And if not, pin 10 must be set to an output even if not used to prevent the arduino from going into SPI slave mode.
CrossRoads:
Most SPI devices need their SS pin to go low to initiate a data transfer, and high when done. Read your device's data sheet.
And if not, pin 10 must be set to an output even if not used to prevent the arduino from going into SPI slave mode.
Thank you. So I can't use pin 10, when I am using isp? Or at least its a bad idea to use pin 10 to do other thing? Since if pin 10 goes low, my arduino becomes a slave, even nothing is connected to it? In my case, only mosi pin and the clk pin is used, so I can't use miso for other thing too? I kinda need these two extra pins to drive my 2 transistors.
As long as pin 10 is an output, your arduino can be SPI master.
Any other pin can be SS for an SPI transfer.
Pin 10 be used for other outputs, or it can be one of several SS pins if you have several devices.
During an SPI transfer, data out on MOSI and at the same time data is clocked in on MISO. So you can't use it as an output to control a transistor.
See page 164 of the '328P data sheet:
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 164.
I suppose one could call
SPI.end();
and then
pinMode (12, OUTPUT);
and then drive the pin low as needed. Use an external pullup to hold the pin while when
SPI.begin();
is called again to send more data out.
I've never tried SPI.end(); so I don't know that it actually exists.
CrossRoads:
As long as pin 10 is an output, your arduino can be SPI master.
Any other pin can be SS for an SPI transfer.
Pin 10 be used for other outputs, or it can be one of several SS pins if you have several devices.
During an SPI transfer, data out on MOSI and at the same time data is clocked in on MISO. So you can't use it as an output to control a transistor.See page 164 of the '328P data sheet:
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 164.I suppose one could call
SPI.end();and then
pinMode (12, OUTPUT);
and then drive the pin low as needed. Use an external pullup to hold the pin while when
SPI.begin();
is called again to send more data out.
I've never tried SPI.end(); so I don't know that it actually exists.
thanks. I will try this out.