E2ForLife

W5100 Driver for PSoC, pt 1

Home  >>  Drivers  >>  W5100 Driver for PSoC, pt 1

W5100 Driver for PSoC, pt 1

On November 26, 2013, Posted by , In Drivers,PSoC, By ,,,, , With 6 Comments

Does Ethernet come easy in a world of 8K of RAM and clock speeds under 100 MHz?  The simple fact is that the TCP/IP protocol stack can become a beast to implement within a small system, and while there are great projects such as Contiki-OS and LWIP, if there isn’t a port already available for the chosen platform you’ll either have to port the code or change the platform (something that is not always achievable).

So, how does one simply just “add” Ethernet to a project that is already underway without blowing the budget, schedule, or creating a generally irate customer that has no more time, money, or patience to wait for something that his “PC already has for free”? Enter the world of the Ethernet Application Specific Integrated Circuit (ASIC), or as sometimes referred to as TCP/IP Chip. WIZnet (www.wiznet.co.kr), a Korean semiconductor company developed a family of “iEthernet” devices that implement the MAC, PHY, buffer memory, and a protocol implementation ASIC.

Simple Block Diagram of W5100

This chip provides everything a budding developer might want in order to implement and Ethernet interface to an embedded device without putting you behind schedule.  Also worth mentioning here is that the Arduino 8-bit AVR boards have been using this device on the Ethernet shield boards.

It also provides the coolness factor of being able to walk in to a room with a working prototype only two days after the “idea” was sprung.

So before getting in to how to make this device in to a quick, inexpensive solution to an otherwise pesky problem, I’ll first get in to some of the specifics related to this family of devices.  Note that while this device offers an excellent solution to the implementation of Ethernet, there are some aspects of the device that might make it a non-ideal end solution.

 

 

Device Features (W5100 iEtherenet):

  • 10/100 BASE-T(X) Ethernet MAC/PHY
  • Protocol Implementation: TCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoE, IP, RAW MAC
  • Power Down Mode + Wake On LAN
  • SPI Mode 0/3 interface with Processor
  • 16K RAM for internal circular buffers
  • Up to 4 simultaneous Socket interfaces
  • Auto MDI/MDIX
  • 3V IO with 5V Tolerance

What’s the downside? Well, with an SPI link between the processor and the Ethernet device (there is also an 8-bit parallel interface), the max data rate achievable is going to be somewhere around 8 Mbit, a usually acceptable data rate for many small embedded devices.  However, if you pay attention to the chip routing on the board, the max tested SPI clock speed is 33 MHz, or roughly 264K bytes per second, which yields a more than adequate data rate for most small embedded devices.

Also, the W5100 lacks a hard-coded MAC address. This could make a handy feature for making embedded hardware that can spoof the address of a computer on a network and capture packets, but for most systems you’ll need a unique MAC address. I’ll address how to get around the MAC address issues later, but simply, this means you’ll need to purchase addresses or a device that has the address pre-programmed (For demo,non-deliverable or test hardware you could always resort to 0x00DEADBEEF00). Also note that Arduino Ethernet shield boards ship with a MAC address that is printed on the sticker on the bottom of the boards.

Next time, I’ll be cracking out the PSoC kit, and hooking up an evaluation module so we can start writing some code to get the W5100 working in a sample application.

If your motivated to just jump right in to the code, the GitHub repository can be found here.

6 Comments so far:

  1. Michael says:

    Interesting , thanks for your good work on the psoc component.

    I hope to use the W5500, once I work out the differences…

    Is there a part 2, for your article?

    Appreciate your work, regards Michael.

    • chuck says:

      Thanks for the feedback. I was working on a part 2, but, became too busy to finish what was quickly becoming a book. I hope to publish a few examples of how to utilize the component and hook up the w5100.

      I too was looking in to the W5500. There are some differences, mainly in the low-level SPI API with the device (it supports burst transfers), and there are some registers that need to be modified. I’ve already spun a W5200 version of the component, and was planning the W5500 version for the future.

      Possibly I detect an opportunity for a combo component for all flavors… hmmm…

      • Michael says:

        Yes I was thinking a combo, perhaps with an api field for device type.

        Also adjustment for buffer sizing, relating to number of ports in use.

        Again, thanks for your quality effort!

        Michael.

  2. Michael says:

    The previous post should read ‘number of sockets in use’

    MJ

  3. Michael says:

    Hi, just been trying your most recent example 1.

    The archive seems in error, when Ioad the workspace for the psoc4 version, I do not show any ‘custom’ components.

    I did try to add the component, that looked OK, and I made all the adjustment expected. No luck!

    Also did an upload of the ‘hex’ file. That worked well.
    Any clues?
    Thanks again, Michael.

    • chuck says:

      Thanks for using the component and providing feedback!

      Usually if the custom components are not being displayed in the “Community Components” tab in Creator it is because the component library is not set as a dependency of the project. You can fix this by right clicking on the project and selecting “Dependancies” from the context menu and checking the box next to the component library.

      I recently uncovered some bugs that were afflicting the PSoC4 specifically, so try the updated version 1.2 code that marks the final release of 1.2. It might fix your issues. Also, if you are still experiencing problems, please send some code and I’ll take a look to see if I notice anything.

Leave a Reply