SPI.Configuration running on a FEZ Panda

Can someone tell me why this does not work?
The first time through the while(true), all the lights on the 74HC595 light up.
But not the second time through.

//References
//FEZPanda_GHIElectronics.NETMF.FEZ
//Microsoft.SPOT.Hardware
//Microsoft.SPOT.Native
//mscorlib
//System

using System;
using Microsoft.SPOT;
using System.Threading;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;

////SPI1 SCK (Clock) Di13
////SPI1 MISO (Input) Di12
////SPI1 MOSI (Output) Di11

namespace LED_Shifter
{
    public class Program
    {
        public static void Main()
        {
            SPI spi;
            SPI.Configuration config;
            config = new SPI.Configuration((Cpu.Pin)FEZ_Pin.Digital.Di10, false, 0, 0, true, true, 250, SPI.SPI_module.SPI1);
            spi = new SPI(config);
            byte[] data = new byte[1];
            
            while (true)
            {
                data[0] = (byte)255;
                spi.WriteRead(data, data);
                Thread.Sleep(1000);
                Debug.Print("Start");
                data[0] = (byte)0;
                spi.WriteRead(data, data);
                Thread.Sleep(1000);
                Debug.Print("End");
            }
            
        }
    }
}

OK, so you should edit your original post (the pencil icon), select all the code and hit the top 101010 icon, and submit it again - that formats code nicely.

74HC595 technically isn’t an SPI device, so you would need to look at the states of pins based on your device’s needs (check the timing diagram in your datasheet). In particular, 74hc595 needs an ENABLE pin (usually pin 13) that is clocked AFTER the byte has been written - and I can only assume you’ve connected it to Di10? I’d be looking to see that this is changing as expected at the end of your transactions - it’ll be hard if you don’t have a logic analyser, but you might have luck with just a multimeter if you are good :slight_smile: or a LED always works for me :slight_smile: :slight_smile:

The good thing is that these are really easy to manually write to, to prove your wiring. You can simply toggle the CLK pin yourself and write out one-bit at a time, then toggle OE when you’ve done the 8-bits. That will show your device is working as it should

Thanks for the clues. I aborted SPI and did it the manual way and it works for what I need. Maybe SPI is a cleaner way but the manual way works and it is easier to see what is going on.

I included my wiring for anyone that cares.

Thanks again.

Now on to the network part.

Keith