Cerbuino SPI1 doesn't work

Hi,
in my first Gadgeteer project i want to use my Cerbuino to do some SPI.
I tried this code:

using System;
using Microsoft.SPOT;
namespace MFConsoleApplication1
{
    using System;
    using System.Threading;
    using Microsoft.SPOT.Hardware;

    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[5];
                byte[] rx_data = new byte[5];

                for (int j = 0; j < 5; j++)
                {
                    tx_data[j] = (byte)j;
                }

                while (true)
                {

                    for (int j = 0; j < 5; j++)
                    {
                        Debug.Print(tx_data[j].ToString());
                    }

                    MySPI.WriteRead(tx_data, rx_data);

                    Thread.Sleep(1000);
                }
         
        }
    }
}

From https://www.ghielectronics.com/docs/45/fez-cerbuino-bee-developer#395
i took, that it uses PB3, PB4 and PB5 for SPI1, which are labeled as 11,12 and 13 on the board.

After successfully downloading my program to the cerbuino, i wasn’t able to see anything on pins 11,12,13 with the scope, except that MOSI is always HIGH.

I tried to use SPI2 in the Configuration, but that gave me an “System.ArgumentException”.

Can someone give me a hint?

I also can’t find out what the GPIO_x pins are on the Cerbuino board!?

Welcome to the forum!

What SPI device are you trying to communicate with?
Are you sure that you are using Cpu.Pin.GPIO_Pin1 as CS pin?

Thanks.
I’m going to communicate with a STM32F4Discovery Board, which will be the Slave.

My code says yes:


SPI.Configuration(Cpu.Pin.GPIO_Pin1,
                 false, 0, 0, false, true, 1000, SPI.SPI_module.SPI1);

But i wasn’t able to find out what the GPIO_Pinx are on the Cerbuino Board.

Ok. Then you just need to choose any available pin and use it as CS.

@ googl1 - How about…

SPI.Configuration MyConfig = new SPI.Configuration(GHI.Hardware.FEZCerb.Pin.PA15, false, 0, 0, false, true, 1000, SPI.SPI_module.SPI1);
1 Like