Communication issues with W5500

Hello,

I’m having difficulty communicating with the chip via web server with Atmega 328pb. Server code below.



#define __AVR_ATmega328PB__
#include "Ethernet.h"

#include "C:/Users/user/source/Workspaces/directory/Directory/Libraries/SPI_Atmega_328PB/SPI/src/SPI.h"

//#include <SPI.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//the IP address for the shield:
IPAddress ip(192, 168, 50, 252 );
// the router's gateway address:
//IPAddress gateway(192, 168, 50, 1);
// the subnet:
//IPAddress subnet( 255, 255, 0, 0 );

EthernetServer server(80);

String readString;

void setup()
{
	Serial.begin(9600);
	while(!Serial) {};
	// initialize the ethernet device
	
	Ethernet.init(PIN_SPI_SS);
	
	Ethernet.begin(mac, ip);
	//Ethernet.setLocalIP(ip);
	Serial.println(Ethernet.localIP());
	
	// Check for Ethernet hardware present
	if (Ethernet.hardwareStatus() == EthernetNoHardware) {
		Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
		while (true) {
			delay(1); // do nothing, no point running without Ethernet hardware
		}
	}
	if (Ethernet.linkStatus() == LinkOFF) {
		Serial.println("Ethernet cable is not connected.");
	}
	
	// start listening for clients
	server.begin();
	Serial.println("Server is at: ");
	Serial.print(Ethernet.localIP());

}

void loop()
{
	// Create a client connection
	EthernetClient client = server.available();

	if (client) {
		Serial.println("new client");
		// an HTTP request ends with a blank line
		bool currentLineIsBlank = true;
		while (client.connected()) {
			if (client.available()) {
				char c = client.read();
				
				//read char by char HTTP request
				if (readString.length() < 100) {
					//store characters to string
					readString += c;
					Serial.print(c);
				}

				//if HTTP request has ended
				if (c == '\n' && currentLineIsBlank) {
					/*
					Serial.println(readString); //print to serial monitor for debuging
					
					client.println("HTTP/1.1 200 OK"); //send new page
					client.println("Content-Type: text/html");

					client.println("Connection: close");  // the connection will be closed after completion of the response
					client.println("Refresh: 5");  // refresh the page automatically every 5 sec

					client.println();
					
					
					client.println("<!DOCTYPE HTML>");
					
					
					client.println("<html>");
					client.println("<HEAD>");
					client.println("<meta name='apple-mobile-web-app-capable' content='yes' />");
					client.println("<meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />");
					
					client.println("<TITLE>hello world</TITLE>");
					client.println("</HEAD>");
					client.println("<BODY>");
					client.println("<H1></H1>");
					client.println("<hr />");
					client.println("<br />");
					client.println("<H2></H2>");
					client.println("<br />");
					client.println("<a href=\"/?button1on\"\">Turn On LED</a>");
					client.println("<a href=\"/?button1off\"\">Turn Off LED</a><br />");
					client.println("<br />");
					client.println("<br />");
					//client.println("<a href=\"/?button2on\"\">Rotate Left</a>");
					//client.println("<a href=\"/?button2off\"\">Rotate Right</a><br />");
					client.println("<p></p>");
					client.println("<br />");
					client.println("</BODY>");
					client.println("</html>");
					break;
					*/
					 client.println("HTTP/1.1 200 OK");
					 client.println("Content-Type: text/html");
					 client.println("Connection: close");  // the connection will be closed after completion of the response
					 client.println("Refresh: 5");  // refresh the page automatically every 5 sec
					 client.println();
					 client.println("<!DOCTYPE HTML>");
					 client.println("<html>");
					 // output the value of each analog input pin
					 for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
						 int sensorReading = analogRead(analogChannel);
						 client.print("analog input ");
						 client.print(analogChannel);
						 client.print(" is ");
						 client.print(sensorReading);
						 client.println("<br />");
					 }
					 client.println("</html>");
					 break;
				}
				if (c == '\n') {
					// you're starting a new line
					currentLineIsBlank = true;
				} else if (c != '\r') {
					// you've gotten a character on the current line
					currentLineIsBlank = false;
				}
				
				//controls the Arduino if you press the buttons
				if (readString.indexOf("?button1on") > 0)
				{
					
				}
				if (readString.indexOf("?button1off") > 0)
				{
					
				}
				if (readString.indexOf("?button2on") > 0)
				{
					
				}
				if (readString.indexOf("?button2off") > 0)
				{
					
				}
				
				//Clear readString for next read
				readString = "";
			}
		}
		// give the web browser time to receive the data
		delay(1);
		// close the connection:
		client.stop();
		Serial.println("client disconnected");
	}
}

Not looking at the code much: 0xdeadbeeffeed is locally administered MAC address! Why people keep selecting it?
Next, explain how the difficulty exhibits itself. More detailed explanation will lead to quicker and effective solution.

Hey, no problem Eugeny. This is the stock server code mostly. I would just like to get this working for validation purposes. List of system components below:
uC: basic I/O nothing special. SPI bus communications works as expected. Can pass commands to W5500 and receive expected results.
Network Switch: Local network. Network Switch shows activity and speed as expected.

If I configured the system as DHCP the W5500 is seen in the router’s DHCP pool.

What is the difficulty you are experiencing? Can you explain it please?
And change MAC address to something different not having two lower bits in first octet set.

I’m having issues receiving data from the network. The W5500 can communicate via SPI with the main uC.

Much better! Now explain what issues are you having with the receiving: what you are sending to the W5500, what it displays in debug output, and what it, from your opinion, does wrong.