W5100 Driver for PSoC, pt 1
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.
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.