Trouble with Default SPI connections on SparkFun SAMD21 Dev Breakout

Hi all,

I am using SparkFun’s SAMD21 Dev Breakout (ID: DEV-13672) to communicate with an SPI flash chip from Alliance memory (part number: AS5F38G04SND-08LIN), but am unable to do so. The chip has QSPI functionality, but I only have it configured for SPI. (SAMD21 doesn’t have QSPI support anyway). I used the SPI header located at the bottom center of the Dev Breakout. This maps to PB10 as MOSI, PB11 as SCK, and PA12 as MISO and I’ve used Arduino digital pins 10 (PA18), digital pin 38 (PA13), digital pin 2 (PA14), and digital pin 3 (PA09) for chip select.

However, when I uploaded the code to the Dev Breakout using the Arduino Zero board definition (and still using the same SPI connections), then everything worked. Furthermore, when I uploaded the code to the Dev Breakout using the SaprkFun SAMD21 Mini Breakout definition (ID: DEV-13664) and used the classic SPI connections on Arduino digital pins 13, 12, 11, and 10, that worked as well.

I haven’t modified the variant files at all. They are in their default configurations. I’ve attached copies of my variant.h and variant.cpp files for reference. The files were located in:

Library/Arduino15/packages/SparkFun/hardware/samd/1.8.3/variants/SparkFun_SAMD21_Dev/variant.h and variant.cpp

I am using Arduino v1.8.19, Arduino SAMD v1.8.13, and SparkFun SAMD v1.8.3. on macOS Monterery v12.5.1 (Apple M1 chip).

I wrote my own SPI library for the flash chip. I’ve also tested the library with an Arduino Due using the Due’s SPI headers. I’ve attached a copy of the library here for reference. Nothing too special. Key functions and constants are listed below:

const SPISettings mySetting(1000000, MSBFIRST, SPI_MODE0); //declared as global constant with the .cpp file

//functions used for each SPI read/write operation
digitalWrite(_cs, LOW);
SPI.beginTransaction(SPISettings(mySetting));

SPI.transfer()

digitalWrite(_cs, HIGH);
SPI.endTransaction();

//setup function in the .ino code
SPI.begin()

The library is called “AS5FxxG04SND” because I would eventually like it work with all the variant flash chips within that family, but I’m currently only testing it with the AS5F38G04SND-08LIN.

I’ve tried SPI speeds of 100 kHz, 1 MHz, 8 MHz, 12 MHz (I was just trying anything at this point), and SPI modes 0 and 3. The chip is compatible with both SPI modes 0 and 3. There is a copy of the data sheet in the attached .zip folder for the library. Regardless, my standard settings are speeds of 1 MHz or 12 MHz and SPI Mode 0.

Any ideas why the SPI headers didn’t work for the SAMD21 Dev Breakout?

Thank you for the suggestions.

AS5FxxG04SND.zip (665 KB)

variant-files.zip (6.52 KB)

Try setting the pins to one of the listed default sercom ones https://learn.sparkfun.com/tutorials/sa … -guide/all and see how that goes

Does the blink example work normally for the SAMD21?