Skip to main content
RJOY.1
Associate II
March 23, 2021
Question

I'm using stm32f407VET6 to work with ethernet using KSZ8895 ethernet switch. To generate the basic MII configuration I'm using STM32 cubeMX. While doing the Ping test I am getting the error 'Destination Host unreachable'.

  • March 23, 2021
  • 0 replies
  • 1423 views

 There is any issue while generating ethernet code using  STM32 cubeMX. The tool chain I am using is TrueStudio. Please help. lwip initialization code is below.

void MX_LWIP_Init(void)

{

IP_ADDRESS[0] = 192;

 IP_ADDRESS[1] = 168;

 IP_ADDRESS[2] = 100;

 IP_ADDRESS[3] = 1;

 NETMASK_ADDRESS[0] = 255;

 NETMASK_ADDRESS[1] = 255;

 NETMASK_ADDRESS[2] = 255;

 NETMASK_ADDRESS[3] = 0;

 GATEWAY_ADDRESS[0] = 192;

 GATEWAY_ADDRESS[1] = 168;

 GATEWAY_ADDRESS[2] = 100;

 GATEWAY_ADDRESS[3] = 3;

  

 /* Initilialize the LwIP stack with RTOS */

 tcpip_init( NULL, NULL );

 /* IP addresses initialization without DHCP (IPv4) */

 IP4_ADDR(&ipaddr, IP_ADDRESS[0], IP_ADDRESS[1], IP_ADDRESS[2], IP_ADDRESS[3]);

 IP4_ADDR(&netmask, NETMASK_ADDRESS[0], NETMASK_ADDRESS[1] , NETMASK_ADDRESS[2], NETMASK_ADDRESS[3]);

 IP4_ADDR(&gw, GATEWAY_ADDRESS[0], GATEWAY_ADDRESS[1], GATEWAY_ADDRESS[2], GATEWAY_ADDRESS[3]);

 /* add the network interface (IPv4/IPv6) with RTOS */

 netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &tcpip_input);

 /* Registers the default network interface */

 netif_set_default(&gnetif);

 if (netif_is_link_up(&gnetif))

 {

  /* When the netif is fully configured this function must be called */

  netif_set_up(&gnetif);

 }

 else

 {

  /* When the netif link is down this function must be called */

  netif_set_down(&gnetif);

 }

Thanks in advance.

Rose

}

This topic has been closed for replies.