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