📜 ⬆️ ⬇️

We connect a new chip from WIZnet: W5500. IP for small things

It seems that Etherent and TCP / IP are still the most common way to communicate a wide variety of devices. Although WiFi has recently been slowly replacing the wired “copper” Etherent, nevertheless, finding a port and “sticking to LAN” is still the easiest way to connect. Such availability of Ethernet has not bypassed the smallest hardware: controllers, sensors, consumption counters, etc. which are now called the fashionable marketing word " Internet of Things * " (Internet Of Things, IoT).



And here we can great help Korean microcircuits from WIZnet. WIZnet is a fairly active manufacturer of IOcP (Internet Offload co-Processor) class chips. What is it? Speaking in human terms, this is a chip that: on the one hand, has Etherent, inside contains its own tiny processor for handling TCP / IP, and on the other hand, a simple interface for communicating with our small piece of hardware.

In the first part there will be a small theoretical overview of the connection of "small pieces of iron" and a bunch of links to different chips.
')
But the question immediately arises: WHY to introduce another processor into the system, if everything can be processed on the main one? Let's try to answer.

Overview: Ethernet for trivia.


Let's try to go "down" on a scale of value (up to units of dollars or even lower) and consider various ways of including "little things" in the network.

The simplest way to “network access” for microcontrollers is various kinds of converters COMport-to-Telnet , Serial2Ethernet sometimes called Reverse Telnet. In this case, the converter “catches” the telnet session and “drives” it to the usual COM port of the microcontroller. Then the operator enters the usual dialogue, only over the network. Well what can I say? First of all, there is a separate microcontroller there too, and the devices are not cheap at all (Articles about homemade module and Tibbo module ). For a simple “change / read one parameter” task, this may well be enough. There are a lot of minuses too - a single session, a fixed protocol - it is difficult, for example, to screw SSL if it is not there, the complexity of configuring the converter itself , for example, changing its IP address or port, etc.

Another option is microcontrollers with a real etherent on board, but they usually have only a MAC level and require an external PHY chip (KS8721BL, DM9161A, RTL8201). Connection with such a chip, MII or RMII at least requires external pins. To connect the PHY to the LAN, you still need to solder the transformer or MagJack. Thus, by the “number of components” there is no gain. Surprisingly, the external Etherent PHY - quite expensive chips, a few dollars per case. But about the same is the entire chip from WIZnet entirely, silicon, in mass production costs a penny. Yes, a transformer for WIZnet is also required, but at the price, there will be no significant gain from the integrated MAC controller. Second: software support for MAC / PHY is quite complex and voluminous. For example, for the STM32Fxx7, the Ethernet source codes of the driver occupy approximately 100K of text in C. ( an article about PICs and Ether ). In addition to the Etherent driver, you also need the TCP / IP stack ( LwIP or uIP ). In addition to the size, you should not forget about the speed of execution (although ... STM32 already exceeds the first Pentium in speed and you can forget about the performance limit).

But what if the benefits of a “full” software IP stack on a microcontroller? Of course have. Consider them later, but for now we continue.

The third option is the SPI Ethernet chip of the Microchip ENC28J60 controller (and the slightly less well-known Silabs CP2200 ), which is deeply loved by the embedderschiki. Please note that these are real Ethernet controllers , not TCP / IP coprocessors. All that a chip can do is receive and receive Etherent frames. That is, the TCP / IP stack will still have to be done by yourself. Yes, there are several ready-made stacks, from wonderful small ones to classic LwIP and uIP.

But still, such a solution is more likely to compete directly with the built-in MAC controller, and the chip price is the same few dollars and about $ 5.7 for a ready-made module (card with a chip, a transformer and an RJ45 socket) on ebay / aliexpress. So back to the products of the company WIZnet.

WIZnet: the middle path.


The first W3100 device was released quite a long time ago, in 2001. It was a full-fledged TCP / IP IOcP (coprocessor) that offered a middle path between the COM port and the MAC controller, implementing the idea of ​​TCP / UDP “sockets” inside the chip. Physically, the W3100 was not a very convenient dual-chip MAC / PHY set, and the real popularity among the “Arduinschikov” (AVR) and “picovods” came to the W5100 device. Suffice it to say that the “official” Arduino Ethernet Shield is built specifically on the W5100.

A lot of time has passed since the W5100 became noticeable: the chip is pretty hot, the network speed is only 10Mbit / s, the chip has several glitches (documented in Errata), the case is quite large due to the presence of a parallel bus, a somewhat nontrivial implementation of SPI. Not surprisingly, WIZnet soon introduced the following model: W5200 . This chip learned to work at 100Mbit, fall asleep and save electricity, lost a parallel connection, it remained purely SPI, which dramatically reduced the number of legs. (He has a brother W5300 to support parallel bus).

The introduction and development of the W5200 went off with a bang! and continues to this day, modules are being released (starting with the native WizNET WIZ820io ) and ending with various Arduin shields, those who are interested can easily find them. For example, slightly less “official” Ethernet Shield V2.0 from the Seeeduino project or Dfrobot's Ethernet Shield for Arduino . And here is a large list of other modules (the list is really big, we shake down).

And finally, in October 2013, WIZnet announced a new W5500 , which was actually planned to be covered in this article (sorry for such a prolonged preface). The chip got a little more convenient.
for LUT self-made builders, the 48LQFN package, a fast “batch” SPI and Cortex M0 inside, which reduced the technical process and power consumption. In general, the chip looks like "W5200 on steroids." Comparison of W5200 and W5500 .

Next, WizNET released the WIZ550io module (there is also a diagram there), and in order not to stay away from “arduinomanii”, WIZnet soon released the Arduino Shield itself (this is just a passive adapter from Arduino to WIZ550io).

But let's not consider Arduino, it will be done without us (for example, right here, on Habré: Ethernet thermometer based on Arduino , etc.) and try to fasten the W5500 to some popular microcontroller, for example to the same STM32. Even WizNET itself is aware of this remarkable family and released the W5200E01-M3 module on the previous W5200 (STM32F103C8 and FT232RQ for USB2Serial). Soon the module on STM32 + W5500 came out: WIZ550web .

By the way, in March 2014, Circuitcellar announced a contest called Connect The Magic (until August 2014) for development using the W5500, and WIZnet dropped prices for chips and modules ( buy ). The competition could win up to 15.000 $. Details on the site, there is also an excellent article .

In the second part (if I add it ...), we will try to fasten the W5500 (or rather WIZ550io) to a small debugging board from Shenzhen LC Technology Co., Ltd. and win $ 15,000 . Scarves are sold on Aliexpress for $ 7.99 and even mentioned several times in Habré.


PS The author has nothing to do with the respected WIZnet company, but gradually the list of links on the W5500 has grown and turned into such a habrapost.

Source: https://habr.com/ru/post/220723/


All Articles