WIZnet Developer Forum

W5500 getSn_RX_RSR always 0

I am trying to do DHCP with a W5500 chip. I am able to send a DHCP discovery message and the DHCP server responds with a DHCP Offer message but the W5500 chip never receives this message (I have checked this with wireshark). I am using FreeRTOS and ESP32. The problem seems to be in getSn_RX_RSR as it always returns 0 so the software never tries to receive data from the chip. I hope you can help me.

Thanks,
Lorien

WIZCHIP_INIT(); // This is SPI configuration

gpio_pad_select_gpio(RST_ETH); // Hard reset W5500
gpio_set_direction(RST_ETH, GPIO_MODE_OUTPUT);

gpio_set_level(RST_ETH, 0);
vTaskDelay(500);
gpio_set_level(RST_ETH, 1);
vTaskDelay(500);

wizchip_sw_reset();

vTaskDelay(200);

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

if(ctlnetwork(CN_SET_NETINFO, (void*) &gWIZNETINFO) < 0) {
    printf("FAILED TO SET NETWORK INFO\n");
}  

xTaskCreate(W5500_timer_task, "W5500_TIMER_TASK", 1024, NULL, 3, &dhcp_timer_task_handle);
  
if(gWIZNETINFO.dhcp == NETINFO_DHCP) {
uint8_t * buffer = malloc(2048);

DHCP_init(SOCK_DHCP, buffer);
reg_dhcp_cbfunc(0, 0, 0);

while(1) {
    uint8_t res = DHCP_run();
    if(res != 1) printf("RES: %d\n", res);
    switch(res) {
        case DHCP_IP_ASSIGN:
            printf("DHCP_IP_ASSIGN!\n");
        case DHCP_IP_CHANGED:
            printf("DHCP_IP_CHANGED!\n");

            break;
        case DHCP_IP_LEASED:
            printf("DHCP_IP_LEASED!\n");
            break;
        case DHCP_FAILED:
            printf("DHCP_FAILED!\n");

            my_dhcp_retry++;
            if(my_dhcp_retry > 20) {
                DHCP_stop();      // if restart, recall DHCP_init()
                #ifdef _MAIN_DEBUG_
                    printf(">> DHCP %d Failed\r\n", my_dhcp_retry);
                #endif
                my_dhcp_retry = 0;
                return -1;
            }
            break;
        default:
            break;
      }
   }
}

return 0;

Nevermind, I had a bug in the spi communications.

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.