PHYCFGR register cannot be read and My code stucks at socket() function

Hi.
I want to transfer data by connecting the W5500 module to the STM32H7 board. I wanted to test it before starting my project. My test code is as follows. My code gets stuck and does not progress in the socket() function. As suggested, i tried to read the PHYCFGR register. i obtained the value of 255 from this register. And when i attempted to set the IP address and other settings at line 80 (You can check my code below, i numbered them), and tried to get all the parameters set in the W5500 at line 83, all the parameters returned with a value of 255. What could be the problem? I believe i have made the GPIO connections correctly. I used SPI5. What should i do?

  1. /* USER CODE BEGIN Header */

  2. /* USER CODE END Header /

  3. / Includes ------------------------------------------------------------------*/

  4. #include “main.h”

  5. /* Private includes ----------------------------------------------------------/

  6. / USER CODE BEGIN Includes */

  7. #include “socket.h”

  8. #include “wizchip_conf.h”

  9. #include <string.h>

  10. #include “loopback/loopback.h”

  11. /* USER CODE END Includes */

  12. /* Private typedef -----------------------------------------------------------/

  13. / USER CODE BEGIN PTD /

  14. int sn = 0;

  15. #define mydata “test\n”

  16. int i = 0;

  17. uint8_t bufSizeTx={2,2,2,2};

  18. uint8_t bufSizeRx={2,2,2,2};

  19. / USER CODE END PTD */

  20. /* Private define ------------------------------------------------------------/

  21. / USER CODE BEGIN PD */

  22. /* USER CODE END PD */

  23. /* Private macro -------------------------------------------------------------/

  24. / USER CODE BEGIN PM */

  25. /* USER CODE END PM */

  26. /* Private variables ---------------------------------------------------------*/

  27. SPI_HandleTypeDef hspi1;

  28. SPI_HandleTypeDef hspi5;

  29. /* USER CODE BEGIN PV */

  30. /* USER CODE END PV */

  31. /* Private function prototypes -----------------------------------------------/

  32. void SystemClock_Config(void);

  33. static void MX_GPIO_Init(void);

  34. static void MX_SPI1_Init(void);

  35. static void MX_SPI5_Init(void);

  36. / USER CODE BEGIN PFP */

  37. /* USER CODE END PFP */

  38. /* Private user code ---------------------------------------------------------/

  39. / USER CODE BEGIN 0 */

  40. void W5500_Select(void) {

  41. HAL_GPIO_WritePin(W5500_CS_EX_GPIO_Port, W5500_CS_EX_Pin, GPIO_PIN_RESET);

}

  1. void W5500_Unselect(void) {
  2. HAL_GPIO_WritePin(W5500_CS_EX_GPIO_Port, W5500_CS_EX_Pin, GPIO_PIN_SET);

}

  1. uint8_t spi_rb(void){
  2. uint8_t cdata;
  3. HAL_SPI_Receive(&hspi5, &cdata, sizeof(cdata), 100);
  4. return cdata;

}

  1. void spi_wb(uint8_t b){
  2. HAL_SPI_Transmit(&hspi5, &b, sizeof(b), 100);

}

  1. enum Status
    {

  2. Failed = 0,

  3. Success = 1
    };

  4. uint8_t validSetNetInfoResult(wiz_NetInfo* _set, wiz_NetInfo* _get)
    {

  5. return(!memcmp(_set, _get, sizeof(wiz_NetInfo)));
    }

  6. /* USER CODE END 0 */

  7. /**

    • @brief The application entry point.
    • @retval int
  8. /

  9. int main(void)
    {

  10. / USER CODE BEGIN 1 */

  11. /* USER CODE END 1 */

  12. /* MCU Configuration--------------------------------------------------------*/

  13. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

  14. HAL_Init();

  15. /* USER CODE BEGIN Init */

  16. /* USER CODE END Init */

  17. /* Configure the system clock */

  18. SystemClock_Config();

  19. /* USER CODE BEGIN SysInit */

  20. /* USER CODE END SysInit */

  21. /* Initialize all configured peripherals /

  22. MX_GPIO_Init();

  23. //MX_SPI1_Init();

  24. MX_SPI5_Init();

  25. / USER CODE BEGIN 2 */

  26. reg_wizchip_cs_cbfunc(W5500_Select,W5500_Unselect);

  27. reg_wizchip_spi_cbfunc(spi_rb, spi_wb);

  28. wiz_NetInfo gGetNetInfo;

  29. wiz_NetInfo gSetNetInfo = {
    .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef},
    .ip = {192,168,2,192},
    .sn = {255, 255,255,0},
    .gw = {192,168,2,1},
    .dns = {130,130,130,130},
    .dhcp = NETINFO_STATIC};

  30. wizchip_setnetinfo(&gSetNetInfo);

  31. HAL_Delay(100);

  32. wizchip_getnetinfo(&gGetNetInfo);

  33. HAL_Delay(100);

  34. wizchip_init(bufSizeTx, bufSizeRx);

  35. HAL_Delay(100);

  36. uint16_t port = 8880;

  37. socket(sn, Sn_MR_TCP, port, SF_TCP_NODELAY);

  38. HAL_Delay(1000);

  39. connect(sn, gSetNetInfo.ip, port);

  40. HAL_Delay(1000);

  41. /* USER CODE END 2 */

  42. /* Infinite loop /

  43. / USER CODE BEGIN WHILE /

  44. while (1)
    {

  45. / USER CODE END WHILE */

97. /* USER CODE BEGIN 3 */


98. i ++;
99. send(sn, &mydata, strlen(mydata));
100. if (i == 2){
101. 	break;
}

}

  1. close(sn);
  2. /* USER CODE END 3 */
    }