I’m new here, and I hope you can help me out. Searching for days ...
I'm struggling with the SPI interface on the SAMD series. In the code below, I've managed to get the SPI running (Version A) – but when I try to adjust the access to make the SPI compatible with other devices (Click Shield), I can't get any SPI communication going (Version B).
What am I doing wrong?
Board: Adafruit Metro M0 Express (SAMD21)
Arduino IDE 2.3.3
All libraries are up-to-date.
Thank you!
include <Adafruit_SPIDevice.h>
#include <Adafruit_MAX31865.h>
#include <wiring_private.h>
// Pin-configuration because of "Arduino UNO Click SHIELD"
#define C_pinMISO 13
#define C_pinCLK 11
#define C_pinMOSI 12
#define C_pinCS_PT1000_1 8
// ************************************************************
// Version A is working, all OK -> Hardware is OK
// Adafruit_MAX31865 thermo1 = Adafruit_MAX31865(C_pinCS_PT1000_1, C_pinMOSI, C_pinMISO, C_pinCLK);
// ************************************************************
// Version B is not working, no SPI-communication
SPIClass mySPI(&sercom1, C_pinMISO, C_pinCLK, C_pinMOSI, SPI_PAD_0_SCK_1, SERCOM_RX_PAD_3); // Also tried sercom0
Adafruit_MAX31865 thermo1 = Adafruit_MAX31865(C_pinCS_PT1000_1, &mySPI);
// ************************************************************
// Also not working. It's the Hardware SPI?
// Adafruit_MAX31865 thermo1 = Adafruit_MAX31865(C_pinCS_PT1000_1);
// ************************************************************
void setup()
{
Serial.begin(115200);
Serial.println("Adafruit MAX31865 PT1000 Sensor Test!");
// mySPI.begin(); Only tried in Version B. No Change.
/* Also tried in Version B. No change.
pinPeripheral(C_pinMISO, PIO_SERCOM1);
pinPeripheral(C_pinCLK, PIO_SERCOM);
pinPeripheral(C_pinMOSI, PIO_SERCOM);
*/
if (!thermo1.begin(MAX31865_2WIRE))
{
Serial.println("ERROR Adafruit PT1000"); // This line is never printed
}
}
void loop()
{
uint16_t rtd1 = thermo1.readRTD(); // Reading Value over SPI. In case of error: 0
Serial.print(" Ratio of input = "); Serial.println(rtd1);
delay(1000);
}
I’m still stuck and I could really use some help, please.
Please let me update the situation:
I tried another PIN-Configuration – no change.
I haved reduced my problem to the example below and this question: Why does Version B in the code doesn’t work?
Version A is working – that means, pin-definition and hardware seems OK.
In this example I use only
Board: Adafruit Metro M0 Express (SAMD21)
2 x MAX31865 Chip, this one on ChipSelect 8 is used
Arduino IDE 2.3.3
All libraries are up-to-date.
#include <Adafruit_SPIDevice.h>
#include <Adafruit_MAX31865.h>
#include <wiring_private.h>
// Pin-configuration is given because of "Arduino UNO Click SHIELD"
#define C_pinMOSI 11 // Metro M0 (SAMD21): Sercom1.0 (-> SPI_PAD_0_SCK_*)
#define C_pinMISO 12 // Metro M0 (SAMD21): Sercom1.3 (-> SERCOM_RX_PAD_3)
#define C_pinCLK 13 // Metro M0 (SAMD21): Sercom1.1 (-> SPI_PAD_*_SCK_1)
#define C_pinCS_PT1000_1 8
// ************************************************************
// Version A is working, all OK -> Hardware is OK
// Adafruit_MAX31865 thermo1 = Adafruit_MAX31865(C_pinCS_PT1000_1, C_pinMOSI, C_pinMISO, C_pinCLK);
// ************************************************************
// Version B is not working, no SPI-communication
SPIClass mySPI(&sercom1, C_pinMISO, C_pinCLK, C_pinMOSI, SPI_PAD_0_SCK_1, SERCOM_RX_PAD_3); // Also tried sercom3
Adafruit_MAX31865 thermo1 = Adafruit_MAX31865(C_pinCS_PT1000_1, &mySPI);
// ************************************************************
// Also not working. It's the Hardware SPI, Default SPI??
// Adafruit_MAX31865 thermo1 = Adafruit_MAX31865(C_pinCS_PT1000_1);
// ************************************************************
void setup()
{
Serial.begin(115200);
Serial.println("Adafruit MAX31865 PT1000 Sensor Test!");
mySPI.begin(); // returns void
pinPeripheral(C_pinMOSI, PIO_SERCOM);
pinPeripheral(C_pinMISO, PIO_SERCOM);
pinPeripheral(C_pinCLK, PIO_SERCOM);
if (!thermo1.begin(MAX31865_2WIRE))
{
Serial.println("ERROR Adafruit PT1000"); // This line is never printed
}
}
void loop()
{
uint16_t rtd1 = thermo1.readRTD(); // Reading Value over SPI. In case of error: 0 or 32767
Serial.print(" Ratio of input = "); Serial.println(rtd1);
delay(1000);
}