The most basic thing for W5300 operation is to write & read desired value to W5300 register.
The function to read/write from register is included in the Wiznet ioLibrary Driver, and users need to port it to match with the board.
First, copy & paste W5300 related code from Ethernet folder of downloaded ioLibrary, and try to compile it.
Errors below will be thrown.
“Header file or directory is missing” error will be thrown.
It can be solved by adding following to ioLibrary include paths in STM32CubeIDE envinronment settings
../Src
../Src/ioLibrary_Driver-master/Ethernet
../Src/ioLibrary_Driver-master/Ethernet/w5300
If code compiles successfully, users need to port ioLibrary for the board.
It is necessary to create functions for W5300 reset, register read (W5300_read) and write (W5300_write)
Let’s add to the main() code and test writing/reading into W5300 SHAR register.
After running the code, it is possible to check through serial port if read value is same with value written into W5300 SHAR register.
Now, let's use loopback.c for the W5300 TCP Loopback Test.
First, set default network value in wiz_Netinfo structure.
Complete the TCP loop test firmware code by periodically calling the loopback_tcps() function in the main loop to handle the TCP protocol.
After running the code, network information is shown and TCP loopback server is running.
If the firmware is running normally, it is possible to test the network transmission rate using WIZnet's Loopback Test Program Ax.
[1] iInChip Send: 20.5430 Mbps(12470418 bytes, 4.6314 sec)
iInChip Recv: 20.4434 Mbps(12470418 bytes, 4.6539 sec)
-------------------------------------------------------
Comparing to 30Mbps result from STM32F4 embedded Ethernet Controller TCP loopback transmission test, the transmission result of 20Mbps is less than expectations.
However, it seems that we can test various examples of network-related applications with ioLibrary.
OptimizationSince the ioLibrary is a standardized code and written to support a variety of hardware, maximum performance requires optimization to fit the hardware.
To speed up the network transmission, W5300 needs to be read and written to the W5300 as quickly as possible by modifying the WIZCHIP_WRITE(), WIZCHIP_READ() functions in the w5300.c file.
If modified as shown in the code below, memory can be accessed immediately without any delay through the function pointer.
If we use DMA on this part, we can improve the performance further.
WIZCHIP_WRITE() Function
WIZCHIP_READ() Function
After optimizing, transmission rate of 62Mbps (7.7MBytes) was achieved when using the same code.
(This figure also depends on Host CPU speed - tested on i7-9300 @3Ghz)
As one frame is 614400 bytes (640x480x2) for 640x480 video, it is likely to be capable to transmit 12 frames at 7.7Mbytes/s.
Let'sl test network video transmission in another post.
ApplicationThe advantage of the IoLibrary standardized code is that it is easy to write various network applications,
With reference to Wiz550web sample code (https://github.com/Wiznet/WIZ550web) it is easy to setup the Web Server and control the board.
Jong Ho Park

Comments