Can 2 spi configs live on the same bus?

So after much hell I’ve finally narrowed down a problem in my application. I have 2 spi devices on the same bus (SPI1) which have a slightly different configuration. It seems however that constantly switching the configuration of a single spi port object, has some sort of delay or, has a bug.
Here are the 2 configurations:


    private static SPI.Configuration config = new SPI.Configuration((Cpu.Pin)FEZCerbuino.Pin.Gadgeteer.Socket1.Pin4,
            false, // Chip Select, active-low
            1, // 1 millisecond setup time
            1, // 1 millisecond hold time
            true, // Clock low on idle (this is the value that's problematic)
            true, // Data valid on falling edge
            5000, // 5Mhz Clock Rate
            SPI.SPI_module.SPI1);

and


config = new SPI.Configuration(chipSelect,
           false,      // CS active state 
           1,          // CS setup time
           1,          // CS hold time
           false,      // clock is idle when SCLK is in this state (this is the problem value)
           true,       // true=sample on rising edge; false=falling edge
           5000,       // Clock rate, in kHz
           bus.Config.SPI_mod);

They are declared in 2 different places so it’s not the same object in the same class that I’m setting :slight_smile:

The first config is for a bank of 7 L6470’s. The second device is a Wiznet 5100 Ethernet module. Whenever I switch the spi configurations, the L6470s work fine but I can’t communicate with the Wiznet Module. Also, this phenomenon only manifests itself when I’m not debugging. With the debugger attached, they behave themselves and work 90% of the time. I’m using a lock{} to prevent other threads changing the config when one thread is using the spi port.

How do I mitigate this problem?