---
title: "w5500 incorrect version value get"
url: "https://maker.wiznet.io/forum/14467"
markdown_url: "https://maker.wiznet.io/forum/14467/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "goolmsan"
created: "2022-02-08T02:27:20+09:00"
last_activity: "2022-02-08T05:42:14+09:00"
language: "en"
views: 810
replies: 0
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# w5500 incorrect version value get

## Question

Asked by goolmsan on 2022-02-08 in Ethernet Chips.

Hello.
While implementing mcu and tcp/ip client communication with w5500-based Ethernet shield, there was a problem that the chip version could not be read properly.
**Look at the w5500 datasheet, it is normal to get 0x04 as the version value, but I get 0x00**

But the board is assigned an ip.
If I give the command ping 192.168.0.75 in cmd it will respond.
Also, communication programs such as Hercules or Easytum cannot be used to connect.

**The io library is using version 1.0.2,** and it has been confirmed that there is no problem with the hardware connection.

Which part is the problem?
**And… Unfortunately, I don’t have an oscilloscope…**

Below are the hardware specifications. The code is also attached.
Ethernet shield: <https://www.devicemart.co.kr/goods/view?no=34412>
mcu: [NUCLEO-F411RE | Mbed](https://os.mbed.com/platforms/ST-Nucleo-F411RE/)

**If there is a Korean developer, please reply in Korean…Also, since this is my first time using the forum, please understand that I have edited the post several times.**

```
main.c

/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "spi.h"
#include "usart.h"
#include "gpio.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdio.h>
#include <string.h>

#include "stm32f4xx_hal.h"
#include "loopback.h"
#include "wiz_init.h"
/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
wiz_NetInfo	gWIZNETINFO = {.mac = {0xA8, 0x61, 0x0A, 0xAE, 0x6F, 0xB6},
						   .ip = {192, 168, 0, 75},
						   .sn = {255, 255, 255, 0},
						   .gw = {192, 168, 0, 1},
						   .dns = {0, 0, 0, 0},
						   .dhcp = NETINFO_STATIC};
/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/

/* USER CODE BEGIN PV */

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP */
uint8_t eth0_buf[512];
/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */
	uint8_t ret, NetValue;
  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART2_UART_Init();
  MX_SPI1_Init();
  /* USER CODE BEGIN 2 */
  W5500HardwareReset();
  NetValue = wizSystemInit();
  wizchip_setnetinfo(&gWIZNETINFO);
  print_network_information();

  if(NetValue == 1)
	  printf("\r\nNetwork_Info_Setting_Complete\r\n");
  else
  {
	  while(1)
	  {
		  printf("Network_Setting_ERROR!!\r\n");
		  HAL_Delay(1000);
	  }
  }

  if(getVERSIONR() != 0x04)
	  printf("[%d]VERSION ERROR!!\r\n",getVERSIONR());
  else
	  printf("[%d]VERSION CORRECT\r\n",getVERSIONR());

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
	  ret = loopback_tcps(0, eth0_buf, 11000);

	  /*if(eth0_buf[0] != 0 )
	  {
		  printf("ret = %d, buf = %X[%s]\r\n", ret, eth0_buf[0],eth0_buf);
		  if(eth0_buf[0] == 0x5a)
		  {
			  printf("data = 0x5a \r\n");
			  eth0_buf[0] = 0xA5;
			  ret = send(0, eth0_buf, 1);
		  }
		  else
		  {
			  ret = send(0, eth0_buf, strlen(eth0_buf));
		  }
		  memset(eth0_buf, 0, sizeof(eth0_buf));
	  }*/
  }
  /* USER CODE END 3 */
}

/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Configure the main internal regulator output voltage
  */
  __HAL_RCC_PWR_CLK_ENABLE();
  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
  RCC_OscInitStruct.PLL.PLLM = 16;
  RCC_OscInitStruct.PLL.PLLN = 336;
  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
  RCC_OscInitStruct.PLL.PLLQ = 4;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }
  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  {
    Error_Handler();
  }
}

/* USER CODE BEGIN 4 */
#pragma GCC push_options
#pragma GCC optimize ("O0")
void delayUS(uint32_t us)
{
	//volatile uint32_t counter = 12*us;
	volatile uint32_t counter = 2*us;
	while(counter--);
}
#pragma GCC pop_options
/* USER CODE END 4 */

/**
  * @brief  This function is executed in case of error occurrence.
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */
  __disable_irq();
  while (1)
  {
  }
  /* USER CODE END Error_Handler_Debug */
}

#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t *file, uint32_t line)
{
  /* USER CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
```

```
wiz_init.c

#include "wiz_init.h"
#include "usart.h"
#include "spi.h"

int wizSystemInit(void)
{
	int8_t tmp;
	uint8_t memsize[2][8] = {{2,2,2,2,2,2,2,2},{2,2,2,2,2,2,2,2}};

	W5500DeSelect();

	HAL_Delay(10);

	reg_wizchip_cs_cbfunc(W5500Select, W5500DeSelect);
	reg_wizchip_spi_cbfunc(W5500ReadByte, W5500WriteByte);

	//reg_wizchip_spiburst_cbfunc(W5500ReadBurst, W5500WriteBurst);

	if(ctlwizchip(CW_INIT_WIZCHIP,(void*)memsize) == -1)
	{
		printf("W5500 initialized fail.\r\n");
		return -1;
	}

	if(ctlwizchip(CW_GET_PHYLINK, (void*)&tmp) == -1)
	{
		printf("Unknown PHY Link status.\r\n");
	    return -1;
	}

	return 1;
}

void W5500HardwareReset(void)
{
  HAL_GPIO_WritePin(W5500_RESET_Port ,W5500_RESET_Pin,GPIO_PIN_RESET);
  delayUS(500);
  HAL_GPIO_WritePin(W5500_RESET_Port, W5500_RESET_Pin,GPIO_PIN_SET);
}


void W5500WriteByte(uint8_t txByte)
{
	uint8_t rtnByte;

	W5500Select();

    while (HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY);
    HAL_SPI_TransmitReceive(&hspi1,&txByte,&rtnByte,1,10);
}


unsigned char W5500ReadByte(void)
{
    uint8_t txByte = 0xFF;
    uint8_t rtnByte = 0;

    W5500Select();

    while (HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY);
    HAL_SPI_TransmitReceive(&hspi1,&txByte,&rtnByte,1,10);

    return rtnByte;
}

void W5500WriteBurst(uint8_t* pBuf, uint16_t len)
{
	HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_RESET);
    HAL_SPI_Transmit_DMA(&hspi1, pBuf, len);
}

void W5500ReadBurst(uint8_t* pBuf, uint16_t len)
{
    uint8_t dataout=0xAA;

    HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_RESET);
    HAL_SPI_TransmitReceive_DMA(&hspi1, &dataout, pBuf, len);
}

void W5500Select(void)
{
    HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_RESET);
}

void W5500DeSelect(void)
{
	HAL_Delay(10);
    HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_SET);
}

void Critical_enter(void)
{
	__disable_irq();
}

void Critical_exit(void)
{
	__enable_irq();
}

int isLinked(void)
{
	return(getPHYCFGR() & PHYCFGR_LNK_ON);
}

void print_network_information(void)
{
	printf("\r\n==============Net Info==============\r\n");
	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("SM Mask	   : %d.%d.%d.%d\n\r",gWIZNETINFO.sn[0],gWIZNETINFO.sn[1],gWIZNETINFO.sn[2],gWIZNETINFO.sn[3]);
	printf("Gate way   : %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]);
	printf("==============Net Info==============\r\n");
}
```

```
spi.c

/* Includes ------------------------------------------------------------------*/
#include "spi.h"

/* USER CODE BEGIN 0 */
#include <stdio.h>
#include <string.h>

#include "stm32f4xx_hal.h"
#include "socket.h"
#include "loopback.h"
#include "wizchip_conf.h"
#include "wiz_init.h"
/* USER CODE END 0 */

SPI_HandleTypeDef hspi1;

/* SPI1 init function */
void MX_SPI1_Init(void)
{

  /* USER CODE BEGIN SPI1_Init 0 */

  /* USER CODE END SPI1_Init 0 */

  /* USER CODE BEGIN SPI1_Init 1 */

  /* USER CODE END SPI1_Init 1 */
  hspi1.Instance = SPI1;
  hspi1.Init.Mode = SPI_MODE_MASTER;
  hspi1.Init.Direction = SPI_DIRECTION_2LINES;
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
  hspi1.Init.NSS = SPI_NSS_SOFT;
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  hspi1.Init.CRCPolynomial = 10;
  if (HAL_SPI_Init(&hspi1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN SPI1_Init 2 */

  /* USER CODE END SPI1_Init 2 */

}

void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
{

  GPIO_InitTypeDef GPIO_InitStruct = {0};
  if(spiHandle->Instance==SPI1)
  {
  /* USER CODE BEGIN SPI1_MspInit 0 */

  /* USER CODE END SPI1_MspInit 0 */
    /* SPI1 clock enable */
    __HAL_RCC_SPI1_CLK_ENABLE();

    __HAL_RCC_GPIOA_CLK_ENABLE();
    /**SPI1 GPIO Configuration
    PA5     ------> SPI1_SCK
    PA6     ------> SPI1_MISO
    PA7     ------> SPI1_MOSI
    */
    GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

    /* SPI1 interrupt Init */
    HAL_NVIC_SetPriority(SPI1_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(SPI1_IRQn);
  /* USER CODE BEGIN SPI1_MspInit 1 */

  /* USER CODE END SPI1_MspInit 1 */
  }
}

void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle)
{

  if(spiHandle->Instance==SPI1)
  {
  /* USER CODE BEGIN SPI1_MspDeInit 0 */

  /* USER CODE END SPI1_MspDeInit 0 */
    /* Peripheral clock disable */
    __HAL_RCC_SPI1_CLK_DISABLE();

    /**SPI1 GPIO Configuration
    PA5     ------> SPI1_SCK
    PA6     ------> SPI1_MISO
    PA7     ------> SPI1_MOSI
    */
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);

    /* SPI1 interrupt Deinit */
    HAL_NVIC_DisableIRQ(SPI1_IRQn);
  /* USER CODE BEGIN SPI1_MspDeInit 1 */

  /* USER CODE END SPI1_MspDeInit 1 */
  }
}

/* USER CODE BEGIN 1 */
void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi)
{
	if(hspi->Instance == SPI1)
	{
		W5500DeSelect();
		printf("Data Receive\r\n");
	}
}

void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi)
{
	if(hspi->Instance == SPI1)
	{
		W5500DeSelect();
		printf("Data Transmit\r\n");
	}
}
/* USER CODE END 1 */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
```

---

Source: https://maker.wiznet.io/forum/14467
