[W5100S-EVB-Pico]: How to set PHY_SPEED to 100Mbit/s ?

Hello all,

sorry for making another post, but there is a lack of basic examples on wiznet GitHub…

As a starting point I followed the DHCP_DNS example and modified it into a simple UDP-sender to test the performance on the “PC”-side using “iperf”. However, the bandwidth is limited to 8-9MBit/s and I think the PHY is working at 10MBit/s and not 100Mbit/s. I changed the CPU SYS Clock to 240MHz and the SPI clock used by wiznet driver to 55MHz. I found this post (Can't connect with 100Mbit) where another user found a way to set the 100MBit/s but its not working for me. My minimal code is listed below, but unfortunately it is not working, since the speed is still 10MBit/s. How do I properly set the speed to 100MBit/s ?




int main(){
    /* SYS clock settings of the RP2040 */
    set_sys_clock_khz(PLL_SYS_FREQ_KHZ, true);
    clock_configure(clk_peri, 0, CLOCKS_CLK_PERI_CTRL_AUXSRC_VALUE_CLKSRC_PLL_SYS, PLL_SYS_FREQ_KHZ*1E3, PLL_SYS_FREQ_KHZ*1E3); 

    stdio_init_all();   
    sleep_ms(4000);   

    printf("<%s>: System clock in Hz: %d\n",EXAMPLE_NAME, clock_get_hz(clk_sys));

    printf("<%s>: Launching Wiznet driver...\n",EXAMPLE_NAME);

    /* Launch Wiznet driver */
    wizchip_spi_initialize();   // Initialize the SPI with DMA capability
    wizchip_cris_initialize();  // Initialize cris
    wizchip_reset();            // Reset the Wiznet chipset
    wizchip_initialize();       // Initialize the Wiznet chipset
    wizchip_check();            // Check the Wiznet configuration?


    /* Approach for setting the PHY to 100MBit/s */
    wiz_PhyConf cnf;
    // Ethernet controller
    CHIPUNLOCK();
    setMR2((uint8_t)getMR2() | 0x80);
    CHIPLOCK();
    PHYUNLOCK();
    setPHYCR0(0x00);
    setPHYCR1(0x01);
    PHYLOCK();
    cnf.mode = PHY_MODE_MANUAL;
    cnf.speed = PHY_SPEED_100;
    cnf.duplex = PHY_DUPLEX_FULL;
    ctlwizchip(CW_SET_PHYCONF, (wiz_PhyConf*)&cnf);
    printf("<%s>: Wiznet driver launched\n",EXAMPLE_NAME);

   
    printf("<%s>: Launching network initialization...\n",EXAMPLE_NAME);
    network_initialize(g_net_info); // apply from DHCP
    printf("<%s>: Network initialization done\n",EXAMPLE_NAME);

    /* Initialize UDP socket */
    printf("<%s>: Launching UDP socket initialization\n",EXAMPLE_NAME);
     tcp_socket_retval = socket(0, Sn_MR_UDP, SOCKET_TCP_PORT,0);

    if(tcp_socket_retval !=0){
        printf("<%s>: Failed to create UDP socket\n",EXAMPLE_NAME);
    }
    printf("<%s>:  UDP socket created!\n",EXAMPLE_NAME);

    uint8_t destip[4]={192,168,1,118};
    char buffer_tx[512];

    for(int i=0; i<512; i++){
        buffer_tx[i]=i;
    }

    printf("<%s>: Entering the main loop now!\n",EXAMPLE_NAME);
    while(1) {
        sendto(0,buffer_tx,sizeof(buffer_tx),destip,SOCKET_TCP_PORT);
    }

}

Best regards,
opcodex64

Hello @opcodex64

Please refer to the example code below and check it after adding it.

  1. Change PHY configuration
/* W5x00 configuration header */
#include "wizchip_conf.h"

FUNCTION(void)
{
    /* PHY configuration structure */
    wiz_PhyConf phy_conf;

    /* Configure PHY */
    phy_conf.by = PHY_CONFBY_SW;
    phy_conf.mode = PHY_MODE_MANUAL;
    phy_conf.speed = PHY_SPEED_100;
    phy_conf.duplex = PHY_DUPLEX_FULL;

    /* Apply PHY configuration */
    wizphy_setphyconf(&phy_conf);
}
  1. Reset PHY
FUNCTION(void)
{
    /* Reset PHY */
    wizphy_reset();
}

Additionally, you can use ‘wizpy_getphyconf()’ to get PHY configuration, so please refer to it.

Hello austin,

thanks for your reply! I think it worked for me, since I was able to achieve 14MBit/sec using “iperf” in server mode (TCP). Furthermore, I wrote a simple tcp server application in python where I receive a fixed datasize using the python “recv”-function (socket library!). To calculate the transfer speed, one need the data transmission time and for this I have just calculated the difference between the timestamp before and after the “recv”-function in python. However, for a datasize of approx. 100MBytes I achieve a net speed using TCP protocol of 20-22MBit/sec, which is fine for the W5100S, since the limit is 25MBit/sec max. according the datasheet.

I can share the code after “cleaning it up”, if desired.

Best regards,
opcodex64

Hi @opcodex64

If you can share the code, please share it.

I think it will be helpful not only for W5100S-EVB-Pico but also for many people who use W5100S.

Thank you.