Arduino Pro Mini + SPI

I'm looking at hooking up an SPI device to my Arduino Pro Mini. It's a Mega328. Am I right in assuming that the pins for SPI for the SPI library
are:

MOSI 11
MISO 12
SCK 13

Also, if I use this chip: http://www.cypress.com/?docID=42536 how do I connect the /CS, /WP, and /HOLD pins? Do I connect them to ground since they're '/'?

(Sorry, I'm not much of a hardware guy....)

You should connect /CS (chip select) to the Arduino's SS (slave select) pin. The hardware SS pin is Pin 10 but you can use any pin you like as long as Pin 10 is used as an OUTPUT.

I don't know what the /WP and /HOLD pins do. The datasheet should say what to do with them if you don't need them.

Darn. AltSerial, which I'm using, disables pin 10. Is there a way to select which pins SPI uses?

Is this the correct usage?

#define SS MyCSPin

  digitalWrite(SS,LOW);
  spi_transfer(PU); // power up 
  spi_transfer(0x00); // data byte
  digitalWrite(SS,HIGH);

cptdondo:
Darn. AltSerial, which I'm using, disables pin 10. Is there a way to select which pins SPI uses?

Pin 10 has to be set as an output or the SPI hardware will think your ATmega is the SPI Slave and not the SPI Master.

As I said before, you can use any free pin for Slave Select as long as you keep Pin 10 set as an OUTPUT.

OK, that gives me enough to go on and blow up some hardware :slight_smile: ... Thanks!

SPI goes to header pins 10..13 on Arduino Undo bds, but to "module"
pins 13..16 on the 24-pin Pro Mini, so you'll have to make sure you have
the right ones.

/CS comes from SS, as John said. The '/' means active-low, so you'll want
to connect /WP and /HOLD high for normal operation, as you don't want to
write-protect or keep the fram in the hold-state.

OK, thanks. I'm not sure how to read your answer; are you saying it's possible to modify the SPI pins? I have pins 3,4,5,6,7,11,12 available. I can move 13 but that would require an additional LED on the final board. I cannot move 8,9,10 as they are dedicated to AltSerial.

SPI are D11-12-13 on any '328 based Arduino. They are hardware in the '328 chip and cannot move.*
The only thing you can do is select a different chip select pin; D10 must be set as an output (and can be connected & used with some other device if you want).

  • you can mess with pins_arduino.h and give them different names, but that will not change the physical pin will connect to.

Thanks. Revision 279 of my yet-to-be-prototyped PCB will be ready shortly.... :slight_smile:

You guys are great. There's so much good info here!