Hardware Reference
In-Depth Information
Verifying the Code
Connect the slave to the master as per Figure 10-2 , with pins 13 through 10 connected together between the two
Arduinos for SPI, and connect a separate LED to pin 8.
Figure 10-2. Arduino-to-Arduino SPI connections
Once you've made the physical connections and powered the boards, open a serial connection via USB to the
master. When you enter a single character through serial, that character will be sent to the slave device, and at the
same time receive a byte from the slave. Note that when echoing data, the slave will always be one byte behind; a null
byte will be received back from the first SPI transfer. When the second byte is sent, the first byte will then be echoed.
Should more data from a slave be expected, the master can transmit null bytes until the expected data is all received.
In the case of a slave that echoes, the master will need to send one additional trailing null byte to get back the full
string that it sent. The data sent and received should look like Tables 10-8 and 10-9 . Table 10-9 shows a null byte being
sent at the end of a transmission string.
Table 10-8. Data Transfer Shifting
Transfer #
1
2
3
4
5
6
Sent
S
A
M
P
L
E
Received
-
S
A
M
P
L
 
Search WWH ::




Custom Search