Adding SPI help Grand Central M4

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ericmkube
 
Posts: 6
Joined: Sun Aug 22, 2021 9:11 pm

Adding SPI help Grand Central M4

Post by ericmkube »

Hi all. I've been trying to add another SPI bus to my board to replace sercom5. I've tried several different combinations of pins, but all efforts are failing. I followed the muxing guide but realized that the pins used are not correct so I followed the board schematic and the datasheet for the samd51 instead. I've been trying to edit the variant file to include an SPI bus 2. The bus gets created but doesn't seem to work as the device I'm trying to connect to fails to be detected and works when connected to the native supporter SPI bus. Does anyone have a good combination of pins and sercom to use to accomplish this? It does not need to be on sercom 5, but I will need to keep the i2c bus intact. I am not using uart.

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adding SPI help Grand Central M4

Post by mikeysklar »

@ericmkube,

One forum user came up with a set of pins that worked for a SERCOM additional SPI with a Grand Central M4.

Code: Select all

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"
#include "wiring_private.h" // pinPeripheral() function

SPIClass SPI2 (&sercom5, 9, 11, 12, SPI_PAD_2_SCK_3, SERCOM_RX_PAD_0);
 

#define BME_SCK 11
#define BME_MISO 9
#define BME_MOSI 12
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

//Adafruit_BME680 bme; // I2C
Adafruit_BME680 bme(BME_CS); // hardware SPI
//Adafruit_BME680 bme(BME_CS, BME_MOSI, BME_MISO,  BME_SCK);

void setup() {
  Serial.begin(9600);

  pinPeripheral(9, PIO_SERCOM);
  pinPeripheral(11, PIO_SERCOM_ALT);
  pinPeripheral(12, PIO_SERCOM);

  SPI.setModule(2); 
 
  while (!Serial);
  Serial.println(F("BME680 test"));
  if (!bme.begin()) {
    Serial.println("Could not find a valid BME680 sensor, check wiring!");
    while (1);
  }
viewtopic.php?f=63&t=153721&p=758759&hi ... m4#p758759

User avatar
ericmkube
 
Posts: 6
Joined: Sun Aug 22, 2021 9:11 pm

Re: Adding SPI help Grand Central M4

Post by ericmkube »

This worked for me. Thanks

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adding SPI help Grand Central M4

Post by mikeysklar »

Awesome. Did you need to make any changes?

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”