In this article, I’ll show how to interface an Ethernet controller to an ultra-low power microcontroller based on Arm Cortex M4. The system is composed of two macro parts: first, we have the STM32 Nucleo Board that runs L476RG (Flash memory 1 Mbyte, 128 Kbyte of SRAM, Cortex-M4 up to 80MHz) and second, we have the ethernet chip ENC28J60. It’s a stand-alone ethernet controller that has a built-in MAC interface and gets a 10Base-T PHY iface.
The Nucleo-64 board provides a flexible way to design new proof of concepts or build cheap prototypes, in fact, thanks to morpho headers it’s easy to put in touch the Nucleo-64 with other boards or chips.
The hardware components:
The project runs on RIOT, a free, open-source operating system developed by a grassroots community gathering companies, academia, and hobbyists, distributed all around the world.
RIOT supports most low-power IoT devices and microcontroller architectures (32-bit, 16-bit, 8-bit).
After a brief statement about the hardware and software, let’s dive into the core of the project:
- Interfacing Nucleo64 to Ethernet controller. I suppose you know the fundamental of serial hardware communication, the simplest way to transfer data between two integrated circuits (IC) placed on the same PCB is serial communication like SPI and I2C.
The ethernet controller supports SPI (clock rates of up to 20 MHz), therefore the communication with the host is implemented via SPI. Since both ICs are placed on two independent PCBs the links are floating wires.
Riot-OS supports the Nucleo board and the ethernet transceiver, basically, we have to inform it how the controller is interfaced with the MCU.
- Configure RiotOS. Once the connections between the two boards are ready, we need a networking stack to embed into the Riot-OS build. Riot OS has native support for IPv6 while IPv4 is offered as an external package by the lwIP (LightweightlwIP) stack, which consists of a small independent implementation of the TCP/IP protocol.
Please check out the project hosted on GitHub. Basically is composed of a Makefile that includes a networking setup and hardware setup and a short main.c that enables a shell interface which provides for the reboot, ps and ifconfig commands. As you can verify all project is really tiny and easier.
The video shows:
- On left terminal an arp-scan result where 192.168.1.148 is the IP address that the Nucleo node retrieves from DHCP server.
- On the right terminal, there’s the Riot-OS shell
The bus design is crucial for high-speed communication between two IC placed on the same PBC. In fact, to work at high frequency the bus has to be the right length and the proper impedance. Usually, the standard PCB design tools address this key point. This project uses just floating wires and to be honest I’m astonished that it’s working.