Has anyone managed to use a nano for talking to perhipherals please using spi ?
The Nano uses the same chip as the Uno, so SPI will be no different except that
there is no ICSP header breaking out the SPI signals so you have to use pins
10/11/12/13 directly.
The docs on the nano say thet spi is not supported, i have not tried myself because i do not have one .
I have always used those pins for spi on arduino uno.
(deleted)
Same 328P chip - so the onlines doc's are in error. Can't believe everything you read online! MarkT hit the nail on the head:
D10 - SS
D11 - MOSI
D12 - MISO
D13 - SCK
Be sure to connect GNDs as well.
Thanks, i was trying to understand if it was something to do with libraries not supporting it, but could see no reason for that whatsoever.
Old docs, yes, thing is i saw the same information repeated in several places.
Multiple repetitions of erroneous info does not make it correct.
Look at the Nano schematic on the product page - do you see anything that would prevent D10-11-12-13 from being used?
I've used Nano 3 to connect to nrf24 radio modules via spi. Definitely works.
On the same track.
The nano uses pins 30 and 31 for isp which are not present on the arduino.
I would like to use the same ftdi cable to programme an cut down arduino uno without the usb.
I assume the bootloader needs to be different though.
I have seen references to this before.
Duff post.
I meant the arduino mini and a would like to be able to programme the arduino nano.
Put Uno bootloader on all 328Ps.
Then pins_arduino.h will take care of extra A6, A7 on SMD 328P boards at code compile time.
FTDI connects to +5, Gnd, Reset, SCK, MISO, MOSI; A6/A7 are not an ICSP factor.
Thanks that seems to be a sensible idea.
I am getting a bit confused with the difference between rx tx pins and mosi miso.
They are seperate pins on the chip so what is used for what.
The spi library on my rfid reader uses pins 2,3,4 and 6.
My error, ithink i have it now.
#define SCK (2)
#define MOSI (3)
#define SS (4)
#define MISO (5)
Adafruit_PN532 nfc(SCK, MISO, MOSI, SS);
void setup(void) {
Serial.begin(9600);
Serial.println("Hello!");
can anyone shed light on why this is done please
Rx/tx are the UART IO pins. Clock timing generated internally by the recipient (like 8x the data rate selected), counts clocks to the middle of the bit time and samples there. Data rate can be 1 Mbit/second. There is some inefficiency with a start bit, 1 or 1.5 or stop bits, and a parity bit (1 start & 1 stop at a minimum).
SCK-MISO-MOSI are the SPI pins, with chip select/slave select controlled by software.
SS goes low to select a slave, then SPI hardware puts out data and a clock line, data is clocked into internal shift register on clock edge. Master can clock data out on MOSI and at the same time clock data in on MISO:
inByte = SPI.transfer(outByte); // master sends outByte to slave, receiives inByte from slave.
Data rata can be 8 Mbit/second. No start or stop bytes.
Using this command in Arduino, can clock out a byte every 17 clocks from an array, just over 1uS/byte:
spdr = array[0]; nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
spdr = array[1]; nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
spdr = array[2]; nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
spdr = array[3]; nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
spdr = array[4]; nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
spdr = array[5]; nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
spdr = array[6]; nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
spdr = array[7]; nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
#define SCK (2)
#define MOSI (3)
#define SS (4)
#define MISO (5)
Adafruit_PN532 nfc(SCK, MISO, MOSI, SS);
Appears to be software bit-banging of SPI lines vs using the faster internal SPI hardware.
CrossRoads:
Rx/
Appears to be software bit-banging of SPI lines vs using the faster internal SPI hardware.
Thanks for the explanation.
The reader shield is physically connected to the mosi/miso pins so i am totally baffled as to why those pins are defined, im guessing they must be redefined somewhere else although i have not checked yet.