Share SPI when using ENC28 on Cerbuino Bee

I am attempting to use the same SPI bus for two devices, the ENC28 ethernet module and the older music shield each on its own CS pin. Is it possible to share the SPI with two devices? Since the Cerbunio bee has the ethernet firmware enabled, I never setup the SPI configeration for the ENC28 module. I believe the firmware does all of this for me.

It should work

Thanks Gus. I am not understanding how to set it up.

Reading this article GHI Electronics – Where Hardware Meets Software it shows how to access two devices using the following code.


        SPI.Configuration ConfigDeviceA =
             new SPI.Configuration(Cpu.Pin.GPIO_Pin1,
             false, 0, 0, false, true, 1000, SPI.SPI_module.SPI1);
        SPI.Configuration ConfigDeviceB =
             new SPI.Configuration(Cpu.Pin.GPIO_Pin4,
             false, 0, 0, false, true, 1000, SPI.SPI_module.SPI1);
        SPI MySPI = new SPI(ConfigDeviceA);
 
        byte[] tx_data = new byte[10];
        byte[] rx_data = new byte[10];
        // accessing device A
        MySPI.Config = ConfigDeviceA;
        MySPI.WriteRead(tx_data, rx_data);
 
        // accessing device B
        MySPI.Config = ConfigDeviceB;
        MySPI.WriteRead(tx_data, rx_data);

I am assuming I don’t want to create a new SPI since the ENC28 already is using the SPI.


       SPI MySPI = new SPI(ConfigDeviceA);

The issue I am having is the Cerbuino locks up if I access both devices. I can initialize the network, start playing music, but on the first callback from the network, the device freezes. If I comment out the MP3 code, network work. If I comment out network, MP3 works. I am pretty sure they are using different CS pins.

SPI is a bus. You only work with one device at a time on the same bus.

Just ignore enc28 is there and use SPI normally. You must use chip select pin to your device and in code.