SPI Slave and PIN 13

Hi,

I'm trying to set up my Arduino as an SPI slave, and I'm having trouble getting it to recognize the master. I'm running pretty close to the edge (master is 500 kHz, 2.7-3.6V output, battery operated). I am getting no output from SPI, even though I've verified the correct signals are making it to the arduino with a signal analyzer.

I suspect that this is due to the LED-resistor on pin 13 (SCK), because if I turn off SPI entirely, digitalRead will read the master's SCK properly if connected to PIN 2, but will always read 0 if connected to PIN 13. I've also had issues with this particular master functioning incorrectly if too many probes are attached, so it seems to be particularly sensitive to resistance.

I was wondering if anyone has any suggestions for how to deal with this. Is it possible to change what PIN SCK is on? Or has anyone ever successfully given PIN 13 an LED-ectomy?

I've tried implementing SPI in software using PIN 2 as clock, but at 500 kHz, that's 32 instructions per clock cycle, which isn't enough, so I really need to use the ATMEGA SPI support.

Thanks!

Can you show your code? I have connected together two Unos for SPI testing, here:

Despite the LED on pin 13 in both cases, I didn't have any problems with it.

Are you using a level converter? 3.6V might be a bit low.

I was wondering if anyone has any suggestions for how to deal with this. Is it possible to change what PIN SCK is on?

No, I believe that is in hardware.

natashenka:
I suspect that this is due to the LED-resistor on pin 13 (SCK) ...

Judging by the datasheet, if Vcc is 5V, then a digital 1 should be a minimum of around 2.6V. You could check with an oscilloscope if, with the resistor there (which looks to me to be 500 ohm), the SCK signal reaches 2.6V. If not, the level converter might be the way to go. eg.

I copied the code off your tutorial and tweaked it only a tiny bit. Small world :wink: But considering that I can't get even the most basic signal from the device off pin 13, and other pins work, I strongly suspect this is a hardware issue.

Thanks for the SparkFun link, I've made some highly-questionable step-up/down circuits out of random components in the past, I didn't realize you can buy them pre-made. I think I'll get a couple of these and see if my problem clears up. They're cheaper than an oscilloscope:).

Sounds like you are right. And I think the step-up circuit is likely to be more reliable than just hacking LEDs off the board.