When using the statement SPI.transfer(0x70) , it runs fine on an Uno, but with a Zero it does not return and hangs. The SPI transaction is commenced with
SPI.begin().
Are there any standard modifications to make in code when moving from a Uno to a Zero?
Thanks.
Yes. In fact the last comment is "Are there any simple SPI master/slave demo sketches specifically for the Arduino Zero? ... the sample IDE examples for SPI compile only for the newer ... boards. The IDE doesn't even show any sample SPI sketches when the IDE is configured for the Zero. ..."
I have only found examples using a Uno, nothing with a Zero.
The pins same pins are used on he Zero and the Uno, namely the ICSP header for SPI. This point is addressed in more detail in the thread you linked above.
[quote="RBB01, post:5, topic:883159, full:true"]
The pins same pins are used on the Zero and the Uno, namely the ICSP header for SPI. This point is addressed in more detail in the thread linked above. [/quote]
I will not be able to check the version of the boards for several hours.
I don't have a Zero, but I do have an Adafruit M0 Feather. It uses the same SAMD21 processor chip and the same I/O pins on that chip for the SPI interface. The code below works as expected with no "hangs". The Serial output and logic analyzer traces are also as expected.
BTW, Adafruit has a Tutorial that explains in detail how to instantiate additional serial-type interfaces (including SPI) on other pins using the available SAMD21 SERCOMs.
#include "Arduino.h"
#include <SPI.h>
SPISettings settings(3000000, MSBFIRST, SPI_MODE0);
void setup() {
SPI.begin();
Serial.begin(115200);
delay(1000);
Serial.println("Starting Byte Transfer Over SPI");
SPI.beginTransaction(settings);
SPI.transfer(0x70);
SPI.endTransaction();
Serial.println("Completed Byte Transfer Over SPI");
}
void loop() {
}
Serial Port Output:
Starting Byte Transfer Over SPI
Completed Byte Transfer Over SPI