Add 2nd Hardware SPI port

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
Jimbee
 
Posts: 45
Joined: Wed Aug 01, 2018 12:49 pm

Add 2nd Hardware SPI port

Post by Jimbee »

Hi,
I have been able to add software SPI ports but they are slow. On the grand central M4 is it possible to add a 2nd SPI hardware port. If so, please let me know how to do this.

Thanks,
Jim

User avatar
dastels
 
Posts: 15660
Joined: Tue Oct 20, 2015 3:22 pm

Re: Add 2nd Hardware SPI port

Post by dastels »

This is a good place to start: https://learn.adafruit.com/using-atsamd ... rial-ports

Dave

User avatar
lalith
 
Posts: 12
Joined: Tue Nov 26, 2019 10:13 am

Re: Add 2nd Hardware SPI port

Post by lalith »

I tried the method by the way it is in the link and i am not successful. I am using itsybitsy m4 SAMD51 device. I wanted to use sercom0 and i think I cannot find the pin numbers defined properly in variants.h file for the sercom0. please help me. here is my code: I think the pins are A1, D2(2), A5 I am looking at

Code: Select all

#include "SparkFunLSM6DS3.h"
#include "SPI.h"
#include "wiring_private.h"

SPIClass mySPI (&sercom0, 5, 7, 6, SPI_PAD_2_SCK_3, SERCOM_RX_PAD_1);
int LSM_CS  = 13 ;



void setup() {
  // put your setup code here, to run once:
   pinMode(LSM_CS, OUTPUT);
  mySPI.begin();

  pinPeripheral(5, PIO_SERCOM_ALT);
  pinPeripheral(7, PIO_SERCOM_ALT);
  pinPeripheral(6, PIO_SERCOM_ALT);




}

void loop() {
  // put your main code here, to run repeatedly:

   digitalWrite(LSM_CS, LOW);
  mySPI.transfer(0x88|0x0F);
   int whoami = mySPI.transfer(0x88);
   Serial.println(whoami, HEX);
   digitalWrite(LSM_CS, HIGH);
         
} 
Last edited by Franklin97355 on Fri Jan 17, 2020 2:46 pm, edited 2 times in total.
Reason: Added code tags

User avatar
lalith
 
Posts: 12
Joined: Tue Nov 26, 2019 10:13 am

Re: Add 2nd Hardware SPI port

Post by lalith »

I think the pins are A1, D2(2), A5 I am looking at

User avatar
Jimbee
 
Posts: 45
Joined: Wed Aug 01, 2018 12:49 pm

Re: Add 2nd Hardware SPI port

Post by Jimbee »

Hi Dave,

Thanks for your link. As stated I can create software spi ports no problem but they are slower. I need to create a 2nd hardware port - not sure if this can be done without editing library files.

Thanks,
Jim

User avatar
lalith
 
Posts: 12
Joined: Tue Nov 26, 2019 10:13 am

Re: Add 2nd Hardware SPI port

Post by lalith »

Hi, what do you mean by that you created a software spi port? do you mean using sercom? or bitbanging? can you share the code how you added?

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

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