0

How to start SPI over ICSP header with Metro M0 Express?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

How to start SPI over ICSP header with Metro M0 Express?

by blnkjns on Mon Apr 12, 2021 12:12 pm

I want to start SPI communication on the Metro M0 Express, but the pin-numbers are not accepted by the Arduino IDE. How do I change this code so the right pins are called:
Code: Select all | TOGGLE FULL SIZE
#define SCK ICSP-3
#define MISO ICSP-1
#define MOSI ICSP-4
#define SS 10
#define RST ICSP-5
#define DIO0 9

//433E6 for Asia
//866E6 for Europe
//915E6 for North America
#define BAND 866E6


//packet counter
int counter = 0;


void setup() {
  //initialize Serial Monitor
  Serial.begin(115200);
 
  Serial.println("LoRa Sender Test");

  //SPI LoRa pins
  SPI.begin(SCK, MISO, MOSI, SS);
  //setup LoRa transceiver module
  LoRa.setPins(SS, RST, DIO0);

blnkjns
 
Posts: 663
Joined: Fri Oct 02, 2020 3:33 am

Re: How to start SPI over ICSP header with Metro M0 Express?

by adafruit_support_bill on Mon Apr 12, 2021 12:30 pm

Pin numbers are only required if you want to create a 'bit-bang' software SPI channel. To use the native hardware SPI via the ICSP header, you do not need to specify pin numbers in the begin() function.

To create more hardware SPI ports on an ATSAMDxx processor, you can use SERCOM: https://learn.adafruit.com/using-atsamd ... s/overview

adafruit_support_bill
 
Posts: 81551
Joined: Sat Feb 07, 2009 10:11 am

Re: How to start SPI over ICSP header with Metro M0 Express?

by blnkjns on Mon Apr 12, 2021 12:43 pm

But how does the code know what chip select pin to use?

blnkjns
 
Posts: 663
Joined: Fri Oct 02, 2020 3:33 am

Re: How to start SPI over ICSP header with Metro M0 Express?

by adafruit_support_bill on Mon Apr 12, 2021 12:53 pm

The SS/CS pin is controlled by the library for the specific devices. In the code you posted, you are passing it to the LoRa library.

adafruit_support_bill
 
Posts: 81551
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.