0

Multiple instances of SPI
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Multiple instances of SPI

by jsbuggy1 on Wed Apr 10, 2019 4:23 pm

I have a project that will use the RA8875 display driver and an SD card. Due to the RA8875 having issues with other devices on the SPI bus, I want to use another instance of SPI and a microprocessor that supports more than one SPI data bus. There are many options but for now I am going to learn how to do this with an M0 or M4 processor. I have searched for a couple of days to find an example of how to set up the second SPI but to no avail. Does the SPI library already have the option to create multiple instances of SPI?

I am aware that I can use a tri-state buffer to accomplish this. I specifically want to learn how to use the peripherals of various chips. I want to know how to set up multiple SPI, I2C, UART, etc.

I am using the Arduino IDE.

Ultimately I want to be able to run the touch paint demo using the RA8875 and a SD card but without the tri-state buffer.

I have a Feather M0 Adalogger and would like to just wire up the RA8875 and set up the additional SPI in Arduino IDE.

Any help would be greatly appreciated.

jsbuggy1
 
Posts: 13
Joined: Thu Feb 12, 2015 11:43 am

Re: Multiple instances of SPI

by adafruit_support_mike on Thu Apr 11, 2019 1:13 am

This tutorial shows how to configure the free SERCOMs on a SAMD21 (our M0 series of boards) as new SPI, I2C, or UART interfaces:

https://learn.adafruit.com/using-atsamd ... -a-new-spi

adafruit_support_mike
 
Posts: 57354
Joined: Thu Feb 11, 2010 2:51 pm

Re: Multiple instances of SPI

by jsbuggy1 on Thu Apr 11, 2019 7:43 am

Thank You VERY much.

jsbuggy1
 
Posts: 13
Joined: Thu Feb 12, 2015 11:43 am

Re: Multiple instances of SPI

by jsbuggy1 on Wed Apr 17, 2019 7:17 pm

I now have multiple SPI ports set up on the M0 express but I am not sure how to use them with the libraries. How do I use the SD library but tell it to talk to the newly created SPI port? Somehow I need to tell the compiler that I want to change the MOSI, MISO, SCK, CS, etc. to talk to the desired device. I am assuming that is how it woks. I feel like I am very close to solving this but I am missing the link somewhere.

I am trying to just check that I have it all set up correctly by running the SD cardinfo sketch. The default MOSI, MISO, SCK, CS, etc. pins is what it wants to talk to but I want to be able to tell it which pins to use and when to do it.

Any help would be appreciated.

jsbuggy1
 
Posts: 13
Joined: Thu Feb 12, 2015 11:43 am

Re: Multiple instances of SPI

by adafruit_support_mike on Thu Apr 18, 2019 1:16 am

jsbuggy1 wrote:How do I use the SD library but tell it to talk to the newly created SPI port?

You can't.. that version is hardcoded to use the primary SPI interface.

The SD library is based on William Greiman's SdFat library though, and current versions of that let you specify the SPI interface you want to use:

https://github.com/greiman/SdFat

adafruit_support_mike
 
Posts: 57354
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.