W5100 Reset pin clarification

Hello,

I am working on a project that makes use of the W5100 chip on the FEZ Connect shield, using UDP. I’ve finally gotten the example code in the “Internet of Things” PDF to work, but I noticed that the pin used for the W5100 reset is Di9. However on page 2 in this reference:

[url]http://www.ghielectronics.com/downloads/FEZ/Shield/Broch_FEZ_Connect.pdf[/url]

…it states that the reset pin is Di7.

In the example code I got working, I indeed used Di9. I also saw Di9 used in a few code examples I found in the forum archives here. However the project I cannot get working was written a couple days ago, after reviewing the above reference. Thus I think that one of my problems is that I am using the wrong reset pin–and should be using Di9. I wondered if this is a known with the reference listed above, but I couldn’t find much about it when I searched the forum archives here. Thus I thought I would mention it here in hopes that someone else might have noticed the same thing.

Thanks in advance.

TB

@ tcbetka
Welcome to the community!
I use DI7 in my FEZ Connect Driver, and the schematic for the board also indicates that it uses DI7.

Well, interesting…

Before you posted, I had changed the code that did not work, to use Di9. It then wouldn’t reset the W5100! So I changed it back to Di7, and indeed it does reset the device. But then I wonder why the example code works with Di9?


using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Net;
using GHIElectronics.NETMF.Net.Sockets;
using GHIElectronics.NETMF.Net.NetworkInformation;
using System.Text;
using Socket = GHIElectronics.NETMF.Net.Sockets.Socket;

public class Program
{
   public static void Main()
   {
      byte[] ip = { 192, 168, 1, 100 };
      byte[] subnet = { 255, 255, 255, 0 };
      byte[] gateway = { 192, 168, 1, 254 };
      byte[] mac = { 0x00, 0x26, 0x1C, 0x7B, 0x29,0xE8 };

      // Enable the WIZnet_5100 chipset, on the specified pins
      WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10, (Cpu.Pin)FEZ_Pin.Digital.Di9, true); 
      
      // Enable the program to set and use a static IP address
      NetworkInterface.EnableStaticIP(ip, subnet, gateway, mac);

      // Not sure why we need this when we are specifying a static IP address...
      NetworkInterface.EnableStaticDns(new byte[] { 192, 168, 1, 254 });

      // Create a socket
      Socket mySocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

      // Specify the destination endpoint
      IPAddress DestinationIP = new IPAddress(new byte[] { 192, 168, 1, 254 });
      IPEndPoint DestinationEndPoint = new IPEndPoint(DestinationIP, 2000);

      // Create a string to pass to the PC, then serialize it to a byte array
      String msg = "Hello PC";
      byte[] byteArrayOutputBuffer = Encoding.UTF8.GetBytes(msg);

      while (true)
      {
         // Send the byte array to the PC via the socket
         mySocket.SendTo(byteArrayOutputBuffer, byteArrayOutputBuffer.Length, SocketFlags.None, DestinationEndPoint);

         //while (mySocket.Poll(2000000, SelectMode.SelectRead))
         //{
            // If the amount of data available on the socket is greater than 0
            if (mySocket.Available > 0)
            {
               // Create a byte array to receive incoming UDP data
               byte[] byteArrayInputBuffer = new byte[mySocket.Available];

               // Define a network endpoint
               //EndPoint recEndPoint = new IPEndPoint(IPAddress.Any, 0);
               EndPoint recEndPoint = new IPEndPoint(IPAddress.Any, 2000);

               // Read incoming UDP data from the specified endpoint into the input buffer array
               mySocket.ReceiveFrom(byteArrayInputBuffer, ref recEndPoint);

               // If the data isn't being sent on the same port as we're listening, disgard it
               if (!recEndPoint.Equals(DestinationEndPoint))// Check if the received packet is from the 192.168.0.2
                  continue;

               // Output the received data to the debug console
               Debug.Print(new String(Encoding.UTF8.GetChars(byteArrayInputBuffer)));
            }
         //}
      }
   }
}

Note that I’ve commented out the inner “while” loop, because I am not really sure what it’s doing, and the example code certainly works without it. I didn’t post my UDPServer code, but it’s basically right out of the example in the “Internet of Things” text. So I am perplexed still, on this Di7 vs Di9 thing–but it’s clear that Di7 at least causes my W5100 to reset.

Thanks for your post.

TB

EDIT: Just had a thought… Maybe Di9 is used for reset on the other ethernet controller chips, besides the W5100?

@ tcbetka
Maybe you are looking at an old revision of the eBook?
I just checked rev 1.20 of the Internet of Things book at:

[url]http://www.ghielectronics.com/downloads/FEZ/FEZ_Internet_of_Things_Book.pdf[/url]

On page 30 it indicates that DI7 should be used for reset:

[quote]To initialize the Ethernet controller you need to choose the SPI module connected to Di13,
Di12 and Di11 (SPI.SPI_module.SPI1) on FEZ boards. Also you need to choose Di10 as Chip
Select and Di7 as W5100 Reset.[/quote]

WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10,(Cpu.Pin)FEZ_Pin.Digital.Di7, true);

Well, that’s basically what the Broch_FEZ_Connect.pdf manual (that I referenced in my initial post) says as well. That was my point–the manual says use Di7, but the example uses Di9. And that works. Interestingly, when I changed the reset to Di7 in the example code, it worked as well…lol.

I am going to just use Di7 and be done with it. Maybe, as you alluded to, the use of Di9 has been deprecated in favor of Di7, and the examples in the “Internet of Things” PDF haven’t been updated. No big deal, now that I know about it.

TB

Welcome to the community Tcbetka!
The correct Reset Pin is Di7. :slight_smile:

Right… I got it working with Di7, and it works correctly. I was just curious to know why the code example in the “Internet of Things” used Di9, and this seemed to work?

TB

The code may have used an old shield maybe or it was an error

Sounds reasonable Gus. It did work fine when I changed the sample code to use Di7 for the reset. And my project works fine now, using Di7 as well.

Thanks for the help.

TB

U need to set the correct Reset pin which is Di7 on FEZ Connect. If you set the wrong pin, it will work the first time you deploy an app because it is newly powered up. but when you try to deploy the second time it will not work because the code will not be able to reset the controller because simply it is toggling the wrong pin.

I believe I got it to work with Di7 Joe. Thanks to everyone for the replies…

TB