I have dozens of the SAMD21 Mini Breakout boards and we have used them for many projects. They have worked fine. At the end of last week, I was working on some software for a spectral analyzer and all of a sudden the SPI display stopped working. I have spent many days debugging. I eventually thought I must have damaged the display and didn’t have a replacement on hand, so built a new system with a different SPI display. And then it too didn’t work. I had a different system with a very small SPI OLED display and that worked. I looked at the code and it happened to be using software SPI and not hardware SPI. A bunch more digging and here is what I have found.
In Arduino IDE 2.1.0 with all updated libraries and board support packages (including SparkFun SAMD 1.8.3), when I specify a “SparkFun SAMD21 Mini Breakout” as my target, it instead automatically switches to “SparkFun SAMD21 Dev Breakout”. I don’t recall this happening previously, but I can’t be sure. Now, there is no way to upload code to the SAMD21 Mini which is compiled as a SAMD21 Mini. Instead it is compiled as a SAMD21 Dev.
The PID/VID for the Mini and the Dev are the same. So I’m not sure how Arduino or anything else could distinguish them.
% cd ~/Library/Arduino15/packages/SparkFun/hardware/samd/1.8.3
% egrep 'dev|mini' boards.txt | egrep 'pid|vid'
samd21_dev.vid.0=0x1B4F
samd21_dev.pid.0=0x8D21
samd21_dev.vid.1=0x1B4F
samd21_dev.pid.1=0x0D21
samd21_dev.build.vid=0x1B4F
samd21_dev.build.pid=0x8D21
samd21_mini.vid.0=0x1B4F
samd21_mini.pid.0=0x8D21
samd21_mini.vid.1=0x1B4F
samd21_mini.pid.1=0x0D21
samd21_mini.build.vid=0x1B4F
samd21_mini.build.pid=0x8D21
The SPI pins are defined differently for Mini and Dev. Looking at the Dev graphical datasheet, I don’t even see pins 22,23,24. Not sure what is going on here - are those the pins on the “Legacy SPI header”? Per the graphical datasheet, both Mini and Dev should have same pin numbers for SPI.
% cd ~/Library/Arduino15/packages/SparkFun/hardware/samd/1.8.3/variants
% grep 'define PIN_SPI' SparkFun_SAMD_Mini/variant.h SparkFun_SAMD21_Dev/variant.h
SparkFun_SAMD_Mini/variant.h:#define PIN_SPI_MISO (12u)
SparkFun_SAMD_Mini/variant.h:#define PIN_SPI_MOSI (11u)
SparkFun_SAMD_Mini/variant.h:#define PIN_SPI_SCK (13u)
SparkFun_SAMD_Mini/variant.h:#define PIN_SPI_SS (10u)
SparkFun_SAMD21_Dev/variant.h:#define PIN_SPI_MISO (22u)
SparkFun_SAMD21_Dev/variant.h:#define PIN_SPI_MOSI (23u)
SparkFun_SAMD21_Dev/variant.h:#define PIN_SPI_SCK (24u)
Looking at the variant.h file on github at https://github.com/sparkfun/Arduino_Boa … /variant.h, it hasn’t been modified since 2018. So it must have been working properly for years.
I updated from Arduino IDE 2.0.4 to Arduino IDE 2.1.0 on April 17. I have been using it without problem, but it might be that I’ve been working with other microcontrollers all that time, and this is the first time I’ve gone back to working on the SAMD21 Dev. So maybe it is a bug in Arduino IDE 2.1.0.
So I’m at a loss. How do I coerce Arduino IDE into compiling my code using the SAMD21 Dev definitions? Any other advice on getting SPI to work again? It feels like I’m making some simple stupid mistake, but I can’t figure out what.
Thanks,
Jim