CERB 40 II and SPI - some errors

I have two brand new Cerb40 II with .NET MF 4.2.

It is not possible for me to produce a reasonable spi signal.

Has the firmware a bug? Maybe I should use a Gadgeteer driver? is my code faulty or the used pins?

I used this pins:

MOSI -> PB5
MISO -> PB4
SCK -> PB3
CS -> PB6

And my simple Code:

        
public static void Main()
        {

            SPI.Configuration conf = new SPI.Configuration(
                (Cpu.Pin)FEZCerberus.Pin.PB6, 
                false, 
                0, 
                0, 
                false, 
                true,
                1150, 
                SPI.SPI_module.SPI1);

            SPI spiTest = new SPI(conf);
            Thread.Sleep(200);

            byte[] data = new byte[] { 0xFF, 0xF1, 0xF2, 0xF3, 0xF4 };

            while (true)
            {
                spiTest.Write(data);
                Thread.Sleep(200);
            }
         }

Does anyone have an idea?
Thanks

Not sure that this is actually a problem or not, but the first thing I would be doing is ask do you have the right version of 4.2 firmware (and is there any reason not to be moving to the 4.3 release)? You should use FezConfig to check loader and firmware versions and report back here.

And just to be clear, what you’re seeing is in some cases you see 10 clock pulses and other times you see nine. Can you be clear if these are repeatable, for example is the very first time through your loop 10 and all others 9, or does there appear to be no pattern?

I have on one device 4.2.6.1 and on the other 4.2.0.1.

I have changed my simple code to transfer 1 byte.
The problem is somehow in the clock . Per byte, there are 2 or 3 clock pulses.

           SPI.Configuration conf = new SPI.Configuration(
                (Cpu.Pin)FEZCerberus.Pin.PB6,
                false, 
                0, 
                0, 
                false, 
                true,
                200, 
                SPI.SPI_module.SPI1);

            SPI spiTest = new SPI(conf);
            Thread.Sleep(200);

            //byte[] data = new byte[] { 0xFF, 0xF1, 0xF2, 0xF3, 0xF4 };
            byte[] data = new byte[] { 0x22 };

            int i = 4;
            while (i != 0)
            {
                spiTest.Write(data);
                spiTest.Write(data);
                Thread.Sleep(200);
                i--;
            }

On NETMF 4.3 I would like to most go without, I porting currently a Panda II project to this cerb 40 (but the SPI will not work :’( ). Also I’m using VS2010 yet and I would not switch to VS2012 if I have already VS2013 there. There’s got to go with 4.2!

So part of your issue is bound to be NETMF versions. Before doing anything, please update them to the SAME version, that is the same as your PC has (so deploy the files that came with the GHI SDK you installed).

While I get that there’s no real reason you need to move to netmf 4.3 and VS2012+, you possibly aren’t going to be able to get much help on those old builds either. I’ll test on my Cerb40 at home (8+ hours away) but it’ll be using GHI’s SDK 2014 R5 and 4.3 and VS2013 - so the results may not tell you much about your setup

According to the schematic, SPI1 appears to be PA4/PA5/PA6/PA7 not PB-anything. Can you confirm what pins you’re connected to ?

@ GHI can someone reinstate the Cerb40 (not the “II”) schematic please ?

those pins are correct on a CERB40 but according to the schematic, not a CERB40 II. Have you tried on the ones I listed earlier ?

@ Brett - http://www.ghielectronics.com/downloads/schematic/FEZ_Cerb40_SCH.pdf

1 Like