Skip to content

Surf 5 - Loopback server example in KEIL 5

Surf 5 - Loopback server example in KEIL 5

TheoIm

Published February 07, 2024

Surf 5 - Loopback server example in KEIL 5

Components

Hardware components Software Apps and online services

Project description

This project builds the Loopback example of Surf 5 in KEIL 5. It shows the process of flashing the extracted binary file to Surf 5 in boot mode using the ISP Tool and conducting a Loopback test with Hercules.

If you are experiencing difficulties with the process mentioned above, please refer to the link below.

 

Hardware requirements

Before starting this project, prepare Surf 5 and a micro 5-pin cable, as well as an Ethernet connected to the internet.

 
Step 1: Prepare Software

The following serial terminal program is required for Loopback test, download and install from below links.

Step 2: Prepare hardware

  • Connect ethernet cable to Surf 5 ethernet port.
  • Connect Surf 5 to desktop or laptop using 5 pin micro USB cable.

Step 3: Setup Loopback Example

To test the Loopback example, Open the project file located at 'D:\projects\W7500x-Surf5\Projects\W7500x_StdPeriph_Templates\MDK' path.

Step 3: Setup Loopback Example
  • In the project, right-click on main.c and press 'Remove File 'main.c'' to remove 'main.c'.
Step 3: Setup Loopback Example
 
  • Right-click on the 'User' folder and click 'Add Existing Files to Group 'User'...'.
Step 3: Setup Loopback Example

 

  • Add main.c from the 'W7500x-Surf5\Projects\W7500x_StdPeriph_Examples\WZTOE\WZTOE_Loopback' directory.
Step 3: Setup Loopback Example

 

  • In the 'Network_Config' function in 'main.c', please change the data in the array below to match your network configuration.
static void Network_Config(void)
{
    wiz_NetInfo gWIZNETINFO;

    uint8_t mac_addr[6] = { 0x00, 0x08, 0xDC, 0x01, 0x02, 0x03 };
    uint8_t ip_addr[4] = { 192, 168, 0, 12 };
    uint8_t gw_addr[4] = { 192, 168, 0, 1 }; 
    uint8_t sub_addr[4] = { 255, 255, 255, 0 };
    uint8_t dns_addr[4] = { 8, 8, 8, 8 };
    ...
  • Inside the while loop, the third argument of the 'loopback_tcps' function represents the port. Change the value of the third argument to your desired port.
int main(void)
{
...
...
...
...
    while (1) {
        loopback_tcps(0, test_buf, 5000);
    }
	
	return 0;
}
     

 

  • Press the 'F7' button to build.
Step 3: Setup Loopback Example

 

Step 4: Upload and Run

Loopback Server Mode

  • Please turn on the 'W7500 ISP Tool' for flashing.
Loopback Server Mode

 

  • Click the 'Browse' button in Step 5 of the tool. Then, select W7500x.bin located in the '...\W7500x-Surf5\Projects\W7500x_StdPeriph_Templates\MDK' path.
Loopback Server Mode
Loopback Server Mode

 

  • Enter Surf 5 into boot mode and search for Surf 5's serial port, then press 'Open'.
Loopback Server Mode

 

  • If the connection to the tool is successful, a successful connection message will appear as below.
Loopback Server Mode

 

  • Press the 'Start All Steps' button to start flashing.
Loopback Server Mode
 
  • Open the Hercules program to set client mode [IP Address] and [PORT number] and Connect to the Server.
Loopback Server Mode
 
  • If you send the phrase Loopback Test, you can see that you are sending and receiving data.
Loopback Server Mode

Comments

Comments