Main Site Documentation

Spider SPI


#1

Hello!

I’ve searched the forum and example code and gleaned what I could but
I’m not sure how to make this work.

I am trying to use socket 6 to communicate SPI to an analog devices eval board
with a digital pot (AD5161).

I have a 10 pin connector inserted into socket 6 and then broke out the pins on the other
side of the cable to connect individually to the correct pins on a 25 pin connector into the eval board.

using pin 1 vcc, pin 4 as chip select, 7 & 8 as MOSI & MISO, 9 clock, & 10 gnd.

I believe the electrical connection is ok but my software interface is not doing anything when I write (see no clock or chip select change on osciliscope).

Here is how I configure the SPI:
m_pot1 = new SPI.Configuration(
Cpu.Pin.GPIO_Pin4, // chip select
false, // set low when accessing the chip
0,
0,
true, // clock signal will be set to high while the device is idle
false, // data is sampled on the SPI clock falling edge
1000,
SPI.SPI_module.SPI1); // is this socket 6 on the spider???
m_SPI = new SPI(m_pot1);

I’ve not used this spi interface before so wondering, how does it make the connection to socket 6? I’m assuming this is referenced by SPI.SPI_module.SPI1. I also tried SPI2 but that didn’t work either. Does this configuration look ok?

Also, I’m assuming all I have to do is configure , instantiate a new SPI and then write and all the chip select and clock signals should turn on as defined by the config. Is there another step or am I correct in this assumption?

thanks!


#2

Pin 4 on Socket 6 is actually…

EMX.Pin.IO22;


#3
using Microsoft.SPOT.Hardware;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;

namespace GadgeteerApp1
{
    public partial class Program
    {
 
        void ProgramStarted()
        {
            Cpu.Pin pin4;

            GT.Socket socket = GT.Socket.GetSocket(6, false, null, null);
            pin4 = socket.CpuPins[4];

            //or

            pin4 = GHI.Hardware.EMX.Pin.IO20; // so is actually mapped to Pin 20 on the CPU

            SPI.Configuration m_pot1 = new SPI.Configuration(pin4, // chip select
                                                             false, // set low when accessing the chip
                                                             0,
                                                             0,
                                                             true, // clock signal will be set to high while the device is idle
                                                             false, // data is sampled on the SPI clock falling edge
                                                             1000,
                                                             SPI.SPI_module.SPI1);
        }
    }
}

#4

Thanks Bill,

I think you are correct!
I copied to my code and all of a sudden,
when I write, I can see changes on the ohm meter.

thanks very much for your help!


#5

Your welcome.

Have fun :slight_smile: