W5500 IP config corrupted on ATmega1284p


I have this simple code which assigns IP configuration to W5500. When I tried to run the code on ATmega1284p the chip did not get IP or MAC configuration and display corrupted data and sometimes display 0’s. I believe the ATmega1284p could not write it to W5500. However, when I run the same code on ATmega32 it works with no problems.

I know that SPI is working because I tested the ATmega1284p with SD card module and I could read/write to it. Also, it can read the chip name as shown in the screenshot of UART terminal.

What can be wrong with ATmega1284p and if someone had an experience with a similar issue.

The code:

stdout = &mystdout;

UART_Init(9600);  //UART Initialization
SPI_MasterInit();  //SPI Initialization
reg_wizchip_cs_cbfunc(cs_sel, cs_desel);
reg_wizchip_spi_cbfunc(spi_rb, spi_wb);

/*********** Network Initialization  *************/
//setMR(MR_RST);  //Reset W5500
//wizchip_sw_reset();  //Reset W5500, retain basic network info
wiz_NetInfo netInfo = {
    .mac  = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address
    .ip   = {192, 168, 1, 124},         // IP address
    .sn   = {255, 255, 255, 0},         // Subnet mask
    .dns =  {8,8,8,8},			  // DNS address (google dns)
    .gw   = {192, 168, 1, 1}, // Gateway address
    .dhcp = NETINFO_STATIC
};    //Static IP configuration

wizchip_setnetinfo(&netInfo);  // Set Basic networking Settings
uint8_t  bufSize[] = {2, 2, 2, 2};
wizchip_init(bufSize, bufSize);

wiz_NetInfo gWIZNETINFO;

uint8_t tmpstr[6] = {0,};
ctlwizchip(CW_GET_ID,(void*)tmpstr); // Get WIZCHIP name
printf(" WIZnet chip:  %s \r\n", tmpstr);

printf("MAC Address: %02x:%02x:%02x:%02x:%02x:%02x\n\r",gWIZNETINFO.mac[0],gWIZNETINFO.mac[1],gWIZNETINFO.mac[2],gWIZNETINFO.mac[3],gWIZNETINFO.mac[4],gWIZNETINFO.mac[5]);
printf("IP Address : %d.%d.%d.%d\n\r",gWIZNETINFO.ip[0],gWIZNETINFO.ip[1],gWIZNETINFO.ip[2],gWIZNETINFO.ip[3]);
printf("SN Mask	   : %d.%d.%d.%d\n\r",gWIZNETINFO.sn[0],gWIZNETINFO.sn[1],gWIZNETINFO.sn[2],gWIZNETINFO.sn[3]);
printf("Gateway    : %d.%d.%d.%d\n\r",gWIZNETINFO.gw[0],gWIZNETINFO.gw[1],gWIZNETINFO.gw[2],gWIZNETINFO.gw[3]);
printf("DNS Server : %d.%d.%d.%d\n\r",gWIZNETINFO.dns[0],gWIZNETINFO.dns[1],gWIZNETINFO.dns[2],gWIZNETINFO.dns[3]);

Terminal Screenshot:


Not closely familiar with the library, but it seems this string “W5500” may be hard coded in the library, see here, here and here. Therefore your statement that chip ID display means SPI works properly may not be true.

Check what is really going on the SPI.