Use Teensy 3.1 as Slave first, then Master second

Status
Not open for further replies.

lennon-pledge

New member
Here's the general layout of what I'm trying to do.

In LabView, I have an FPGA that sends a byte of information to my Teensy via SPI. The Teensy acts a slave in this case, the FPGA being the master.

What I want to do next is take that byte (let's say it's 150 in decimal), and use it to test an "if" condition in order to light an LED. This "if" condition being built into the chip on the Teensy.

This is where I want to introduce an SPI-incorporated single-channel digital pot (MCP4151). If the byte in decimal form being transferred is 150, I want to use the Teensy to send 150 to the digital pot to represent the wiper step. The MCP4151 has 0-255 steps, and it's a 50k ohm max. If the 150 gets there, my LED will light up to such a brightness.

Before I try that second task I want to know if this is even possible? Using the Teensy first as a slave, then as a master. Or any other Arduino board for that matter (I will get the necessary board if need be).

Thanks
 
Others can probably answer this better than I can, but:

In order to do what you are talking about sounds like directly, I believe you are talking about using SPI in a multi-master mode. Not sure if the Teensy can do this or not, also not sure if your host would like this or not.

However, there may be another approach. If you purchase a Teensy LC (or one of the soon to be released 3.5 or 3.6), boards, they have multiple SPI busses on their chips.

So for example using Teensy LC, connect the host up to the Teensy using the SPI object (default pins 11, 12, 13 plus CS) and connect your MCP4151 up to the Teensy using SPI1 object, default pins (0, 1, 20).
 
Thank you both for the responses, and I think going with the Teensy LC with multiple SPI busses will be the most prudent. I guess so long as the code is distinct enough to separate the master-slave functionalities there shouldn't be any problems.

There are function options for Teensy 3.1 that allow you to move the SPI to alternate pins but I don't know how reliable that is (e.g. SPI.setMOSI(pin) etc.). Just as a forethought.
 
Status
Not open for further replies.
Back
Top