You don't have the slave's SS pins (pin 10) connected. You do have two wires going to pins 2 for some reason but that won't do anything for SPI.
Read up on SPI's use of the SS pin when the chip is a slave.
BTW you can't just hang a LED form a pin straight to GND, you MUST have a current-limiting resistor.
Also I can't really follow your master code but you seem to do X SPI.transfer()s and then dick with SS1 and SS2 after the transfers?? You have to drop SSx, do the transfers then raise SSx.
Is SPI.attachInterrupt(); valid code? It does compile but I can't see any documentation for it. And if it is valid surely it needs a reference to a function as the parameter.
Thanks Graynomad, the problem was with the SS pin.
And the SPI.attachInterrupt(); is a valid code. I didn't pass the function as parameter because I'm registering the interrupt this way: ISR (SPI_STC_vect)
Apart from no resistors for the LEDs, you have to have the SS line on the slaves to be pin 10, which is what the hardware expects, as Graynomad said.
Also, as he said:
void loop() {
SPI.transfer(0x0F);
for (int i = 0; i < 4; i++) {
pvalor[i] = SPI.transfer(i);
delay(100);
}
Bring the SS line (for one of the slaves) low, transfer data, bring it high again, then do the same for the other slave, as required. Don't have both low at once.
What's the delay for? Do you like code that runs slowly?
Fair enough, I couldn't find any documentation. BTW I still can't, where is this documented?
Another typical example of Arduino bad naming practice. How can something call "attach" simply set a bit and not load a function pointer like the function of the same name does elsewhere. This should be enableInterrupt() or something.
Hi,
I am facing a similar problem. I am using arduino due for SPI communication between 3 Arduinos.
I am not able to use any other pin except for pin No 10 as a SS pin. When i use any other pin i am not able to transfer data. Please let me know what i should do.
The objective of this project is to develop an embedded systems device, namely Datalogger. The user should choose what He/She wants to record through a GUI (Graphical User Interface). For GUI design you could use Python Tkinter or something of your choice.
Note: The thing is, you will be needing 4 Arduinos. Two Arduinos will communicate with each other using SPI. Third Arduino will act as a sniffer and collect the data that is communicated between Arduino 1 and Arduino 2 without interrupting their communication. Then the third Arduino will send this data to the fourth Arduino which is connected to the ethernet port of the Laptop. Then display the data on the GUI in PC/Laptop in a user-readable form. Also, display the data in the LCD display module. The Third Arduino will act as a sniffer.
BharghavNukala:
I have a question regarding SPI Sniffing:
Data logger SPI – Ethernet data
Objective:
The objective of this project is to develop an embedded systems device, namely Datalogger. The user should choose what He/She wants to record through a GUI (Graphical User Interface). For GUI design you could use Python Tkinter or something of your choice.
Note: The thing is, you will be needing 4 Arduinos. Two Arduinos will communicate with each other using SPI. Third Arduino will act as a sniffer and collect the data that is communicated between Arduino 1 and Arduino 2 without interrupting their communication. Then the third Arduino will send this data to the fourth Arduino which is connected to the ethernet port of the Laptop. Then display the data on the GUI in PC/Laptop in a user-readable form. Also, display the data in the LCD display module. The Third Arduino will act as a sniffer.
Waht is your question ?
Are you asking someone to write the code for your 'project' ?
Two Arduinos will communicate with each other using SPI. Third Arduino will act as a sniffer and collect the data that is communicated between Arduino 1 and Arduino 2 without interrupting their communication.
*********My question is how can third arduino be used as sniffer? or do we need to use any other module/component for sniffing the data from arduino without interrupting their communication ********