Main Site Documentation

SPI and sockets type s


#1

This is the example from the documentation of SPI in this site,
My problem is that there are two type S sockets in my hydra sockets 3 and 4, which one of them is this code configure? Where should I plug my SPI device?
Thanks in advance.

  public class Program
  {
      public static void Main()
      {
          SPI.Configuration MyConfig =
               new SPI.Configuration(Cpu.Pin.GPIO_Pin1,
               false, 0, 0, false, true, 1000, SPI.SPI_module.SPI1);
          SPI MySPI = new SPI(MyConfig);
 
          byte[] tx_data = new byte[10];
          byte[] rx_data = new byte[10];
 
          MySPI.WriteRead(tx_data, rx_data);
 
          Thread.Sleep(100);
      }
  }
} 

#2

Can you be more specific ?


#3

Both sockets are SPI1


#4

If you take a look at the schematic, comparing the socket type S of the Gadgeteer Socket Specification to sockets 3 and 4 on the hydra, you will notice that the SPI pins on socket 3 are labeled MISO, MOSI and SCK. If you then look at socket 4 you will notice that the SPI pins are labeled MISO, MOSI and SCK.

This means that for the Hydra, socket 3 and 4 will be referred to as SPI.SPI_module.SPI1 from code.

Edit: SPI pins can be shared throughout a number of different sockets, just make sure you use the appropriate Chip Select pin for the module you are using.


#5

To be clear, there are 2 answers here:

  1. if using vanilla NETMF then you need schematics to determine the pins

  2. if using Gadgeteer (and you should) then the Gadgeteer core will tell you what the pins are, no need for schematics and your device can be moved to any socket and it will still automatically work. For this, see the music module drivers for example on the use of SPI on Gadgeteer.


#6

My problem is that I can’t measure the clock between pin 9 (clock) and 10 (ground), I set it 1000Khz as you see in the constructor but nothing comes up on the fluke. Tried yo change to 1 khz and still nothing, What have i done wrong?


#7

@ bioengproject - are you assuming that the clock is always running? it may only run during reads and writes?


#8

Ok, that’s seems to be it.