G120 SPI port to use for ENC28J60 Ethernet interface

We have made a custom board that uses the G120 SoM. We used SPI2 to interface with an ENC28J60 Ethernet controller. Section 8.6 of the G120 data sheet indicates that SPI2 is used for the on board flash interface and recommends that another SPI port be used. However, the G120E Dev Board uses SPI2 for a WiFi interface.

Can we SPI2 on the G120 for our Ethernet interface?

@ jbrower - Can you use SPI1 for the ethernet?

Some time ago someone mentioned, it should be used another SPI-channel because when a SPI-device should block the bus (maybe because of a malfunction) the G120 can’t access its flash and can’t do anything what results in a complete unresponding unit. But it can be used.

We modified our board to move the ENC28J60 interface to SPI3. We have the same problem where an exception is thrown on this line of code…

GHI.Networking.EthernetENC28J60 ethernet = new EthernetENC28J60(GHI.Pins.G120.SpiBus.Spi3, GHI.Pins.G120.Gpio.P1_10, GHI.Pins.G120.Gpio.P1_9, GHI.Pins.G120.Gpio.P1_5);

We catch the exception with this code:

        catch(Exception ex)
            WriteLine("Exception encountered:");
            WriteLine("Message: " + ex.ToString());

This is the output…

Exception encountered:
Message: System.Exception

Our programmer is saying this is a hardware problem, but the G120 is connected to the Ethernet controller properly.

Can anyone help?

The native SPI to use for Networking on G120 is SPI2.
If I remember right, SPI2 can not be used for anything else.
Also the Cobra II Net board uses SPI2 for ENC28:

We use G120 on our custom board too, with ENC28 on SPI2: No Problems since years.

May be one of the other Pins is already in use?

Our board was laid out to use SPI2, but our programmer found this in the G120/G120E data sheet:

8.6 SPI Channels
SPI2 is shared internally with the flash memory on the G120. Use of a chip select with devices on this channel is required or the G120 will not function properly. The use of another SPI channel is recommended.

Based on this and the responses in this thread, we decided to modify our board and use SPI3 for the Ethernet controller interface.

We had the same exception using SPI2.

I don’t know if thats a problem, that causes an Exception, but I think at least the Interrupt-Pin should have an Interrupt-capability (so pins at port 0 or 2 on the G120)

@ jbrower - glx is probably correct. On the G120 only ports 0 and 2 support interrupts (section 7.1 and 8.3 in the datasheet). It looks like you’re using port 1 for the externalInterrupt parameter in the EthernetENC28J60 constructor.

That’s it! We moved the Ethernet controller interrupt to a pin on port 2 and no exception is thrown and Ethernet is working. Thanks to GLX and John!

1 Like