This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Wiznet5100 ethernet shield on nRF52840

Dear Nordic Devzone,

I want to run an Arduino Ethernet Shield with the Wiznet5100 on the nRF52840. I was wondering if there was an easier way to do this then having to rewrite the SPI code by myself.

www.arduino.cc/.../ArduinoEthernetShieldV1

Currently I am using the Keil IAR /uVision to compile my code and can easily compile and run all the examples included. I am just a bit lost on how to use the ethernet shield with the nRF52840.

I thought I would be able to use some Arduino library to easily get it working.

Any help or direction in which to start would be much appreciated.

ToasTer

  • Hi,

    You can find a nRF5x SPI library for the WIZnet 5500 chip at this github page. This should be a good starting point.

    Also see this blog post about WIZnet's BLE to TCP Gateway.

  • Hey, thanks so much for your quick answer. I will give this a shot this weekend. Will most likely have to retro fit it, but I should be able to do that.

    Thanks again,

    Mark

  • Dear Sigurd,

    Using the link you provided I am now able to compile the whole library and functions.

    In the user_spi.c I changed the spi0_master_init() function to correspond with the SCK, MOSI, MISO, CSN pin layout on the nRF52840 :

    void spi0_master_init()
    {
        SPIConfig_t spi_info = {.Config.Fields.BitOrder = SPI_BITORDER_MSB_LSB,
                            .Config.Fields.Mode     = SPI_MODE3,
                            .Frequency              = SPI_FREQ_8MBPS,
                            .Pin_SCK                = SER_APP_SPIM0_SCK_PIN,
                            .Pin_MOSI               = SER_CON_SPIS_MOSI_PIN,
                            .Pin_MISO               = SER_CON_SPIS_MISO_PIN,
                            .Pin_CSN                = SER_APP_SPIM0_SS_PIN};	
        spi_master_init(SPI0,&spi_info);
    }
    

    Although at this moment I am kind of lost. I followed the example and also called :

    	user_ethernet_init();
    	network_init();
    

    But I can't ping the board. Any tips to help me ?

  • Frist make sure that the SPI pins are connected correctly.

    • SER_APP_SPIM0_SCK_PIN = P0.27
    • SER_CON_SPIS_MOSI_PIN = P0.02
    • SER_CON_SPIS_MISO_PIN = P0.26
    • SER_APP_SPIM0_SS_PIN = P1.13

    There have been some bugs in some libraries with using the port 1 pins in previous SDK version, so you could try to use a different pin for SER_APP_SPIM0_SS_PIN , you could try to use e.g NRF_GPIO_PIN_MAP(0,3) instead of P1.13.

    If you have access to a logic analyzer(e.g saleae logic), you should take look at the data being sent over the SPI lines.

    You could also try debugging, set the optimization level to 0, place some breakpoints, and see if the code is working as it should.

  • Hey Sigurd,

    Thanks for responding, I was using different pins. Because I thought I the pins had to be used corresponding to the pins identified on the Ethernet Shield (wiznet 5100). I tried changing the pins of the rest and the both the SER_APP_SPIM0_SS_PIN to 1.13 and 0.3 pins.

    I also got UART running now and can see some console output from the library you send me earlier. It seems that it is not recognizing the Wiznet5100. Console output below from the network_init(); function

    W5500 NET CONF
    MAC: FF:FF:FF:FF:FF:FF
    SIP: 255.255.255.255
    GAR: 255.255.255.255
    SUB: 255.255.255.255
    DNS: 8.8.8.8
    

    So it seems that things are going wrong with the SPI, if I check the example you send me they are using different pins.

    Will try the debugging but at this moment I do not have a logic analyzer.

Related