The ETH W5500 Spare Part in PICSimLab: What It Does
Among PICSimLab’s spare parts, the ETH w5500 (in the Others category) is the one most often oversold in third-party tutorials. This page sticks to what the official documentation supports: the part adds a W5500 Ethernet shield model to your simulation. What it does not do is write your network firmware for you — and the documentation does not promise full network-stack emulation. Here is how to set the part up correctly and what to expect from it.
What you need
- PICSimLab 0.9.3 — see the download page.
- MPLAB X IDE and the XC8 compiler.
- Board: McLab2 or PICGenios with a PIC that has an MSSP SPI module — this tutorial uses the PIC16F877A as the example host.
- One ETH w5500 spare part, and a W5500 driver for your firmware project (see step 3 — PICSimLab does not supply application firmware).
- Recommended first: the UART tutorial, so you have serial logging while bringing up SPI devices.
Wiring used in this tutorial (example)
The W5500 is an SPI device. On the PIC16F877A the hardware SPI (MSSP) pins are:
- SCK → RC3, SDI (MISO) → RC4, SDO (MOSI) → RC5
- Chip select (example) → RB0 — a normal GPIO you drive yourself
Open the ETH w5500 part’s Properties (right-click the part after adding it) and connect its SPI lines to these pins. The chip-select pin is your choice; just keep the firmware and the Properties window in agreement.
Steps
1. Generate the project and add the part
Create the MPLAB X project for the PIC16F877A. Open Modules → Spare parts and add Others → ETH w5500. Set its connections in Properties as above, and save the spare-parts configuration (.pcf) from the window’s File menu so the wiring survives restarts.
2. Bring up SPI first, without the network stack
Before any Ethernet code, prove the SPI bus: initialise the MSSP as an SPI master and read a known W5500 register (the VERSIONR register, which a real W5500 answers with 0x04) in a tiny test program, logging the result over the UART from the earlier tutorial. If the version read fails in simulation, the problem is wiring or SPI mode — not your TCP code.
3. Add a W5500 driver to your firmware
PICSimLab simulates hardware; it does not include your application. A W5500 driver (the chip vendor’s ioLibrary is the usual starting point on real projects) must be ported to XC8 and to your SPI read/write functions, with realistic expectations about effort: small PICs have limited RAM for socket buffers, so keep the test program minimal — for example, initialise the chip, set a static IP configuration in code and open one socket.
4. Set honest expectations for the simulation
The official PICSimLab spare-parts documentation confirms the ETH w5500 part exists and how it is added; it does not publish a coverage matrix for network protocols. Treat the simulation as a way to develop and debug your SPI driver and program flow. Anything that depends on a real LAN — DHCP servers, real peers, internet services, throughput — belongs on real hardware with a real W5500. Tutorials that promise full Ethernet projects “just like real hardware” in the simulator are going beyond the documentation.
Example code: SPI version check (XC8)
// Example: MSSP SPI master + W5500 version register read
// PIC16F877A, XC8. SCK=RC3, SDI=RC4, SDO=RC5, CS=RB0 (example)
#pragma config FOSC = HS
#pragma config WDTE = OFF
#pragma config PWRTE = ON
#pragma config BOREN = ON
#pragma config LVP = OFF
#pragma config CPD = OFF
#pragma config WRT = OFF
#pragma config CP = OFF
#include <xc.h>
#define _XTAL_FREQ 20000000 // Example: match the board clock
#define W5500_CS PORTBbits.RB0
void spi_init(void) {
TRISCbits.TRISC3 = 0; // SCK output
TRISCbits.TRISC4 = 1; // SDI input
TRISCbits.TRISC5 = 0; // SDO output
TRISBbits.TRISB0 = 0; // CS output
W5500_CS = 1; // deselected
SSPSTAT = 0x40; // CKE=1, sample at middle
SSPCON = 0x21; // SPI master, Fosc/16, idle low
}
unsigned char spi_transfer(unsigned char b) {
SSPBUF = b;
while (!SSPSTATbits.BF) { }
return SSPBUF;
}
// W5500 VERSIONR is at block 0, address 0x0039; value should be 0x04
unsigned char w5500_read_version(void) {
W5500_CS = 0;
spi_transfer(0x00); // address high byte
spi_transfer(0x39); // address low byte
spi_transfer(0x00); // read, block 0
unsigned char v = spi_transfer(0xFF);
W5500_CS = 1;
return v;
}
Use w5500_read_version() from your test main with the result sent to the UART or shown on LEDs — it separates “SPI works” from “network stack works”, which saves hours.
Try next
- UART serial — the debug channel every network bring-up needs.
- LCD over I2C (PCF8574) — another bus peripheral, with a gentler learning curve than Ethernet.
- Oscilloscope basics — sanity-check SCK and chip-select timing.
Troubleshooting
The version register does not read 0x04. Work the SPI checklist: CS actually toggling, SDI/SDO not swapped in Properties, CKE/CKP settings, and the correct three-byte header before the data byte. Change one thing at a time and retest.
The driver compiles but nothing network-related happens. That is the expected boundary of the simulation if your code depends on a live network. Keep driver and SPI debugging in PICSimLab; schedule protocol testing on real hardware.
