---
title: "Surf 5 - Loopback server example in KEIL 5"
url: "https://maker.wiznet.io/TheoIm/projects/surf-5-loopback-server-example-in-keil-5/"
markdown_url: "https://maker.wiznet.io/TheoIm/projects/surf-5-loopback-server-example-in-keil-5/md"
type: "WCC: WIZnet Created Content"
author: "theo"
author_url: "https://maker.wiznet.io/TheoIm/"
original_author: "Theo"
published: "2024-02-07"
language: "en"
tags: ["surf5-contest-ref"]
hardware: ["WIZnet W7500"]
likes: 6
views: 2713
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# Surf 5 - Loopback server example in KEIL 5

> Surf 5 - Loopback server example in KEIL 5

Original author: Theo

## Components

- **WIZnet W7500** x 1 ([docs](https://docs.wiznet.io/Product/Chip/MCU/W7500))
- Software: **ARM KEIL5** ([docs](https://www2.keil.com/mdk5))

## Article

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.**

- [**Surf 5 Library**](https://github.com/Wiznet/W7500x-Surf5)

- [**ISP Tool**](https://maker.wiznet.io/jaden/projects/how%2Dto%2Dflash%2Dsurf5%2Dusing%2Disp%2Dtool/?serob=rd&serterm=month)

- [**How to make Surf 5 projects in Keil 5**](https://maker.wiznet.io/TheoIm/projects/how%2Dto%2Dmake%2Dsurf%2D5%2Dproject%2Din%2Dkeil%2D5/?serob=rd&serterm=month)

### **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.

- [**Hercules**](https://www.hw-group.com/software/hercules-setup-utility)

- **ISP Tool**

### **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.

![](https://maker.wiznet.io/upload/ckeditor5/57019074%5F1707228727%2Epng)

- In the project, right-click on main.c and press 'Remove File 'main.c'' to remove 'main.c'.

![](https://maker.wiznet.io/upload/ckeditor5/57019074%5F1707229049%2Epng)

- Right-click on the 'User' folder and click 'Add Existing Files to Group 'User'...'.

![](https://maker.wiznet.io/upload/ckeditor5/57019074%5F1707229234%2Epng)

- Add main.c from the 'W7500x-Surf5\Projects\W7500x_StdPeriph_Examples\WZTOE\WZTOE_Loopback' directory.

![](https://maker.wiznet.io/upload/ckeditor5/57019074%5F1707229450%2Epng)

- In the 'Network_Config' function in 'main.c', please change the data in the array below to match your network configuration.

```plaintext
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.

```plaintext
int main(void)
{
...
...
...
...
    while (1) {
        loopback_tcps(0, test_buf, 5000);
    }
	
	return 0;
}
```

- Press the 'F7' button to build.

![](https://maker.wiznet.io/upload/ckeditor5/57019074%5F1707229663%2Epng)

### **Step 4: Upload and Run**

### **Loopback Server Mode**

- Please turn on the '**W7500 ISP Tool**' for flashing.

![](https://maker.wiznet.io/upload/ckeditor5/57018711%5F1707211196%2Epng)

- 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.

![](https://maker.wiznet.io/upload/ckeditor5/57018711%5F1707211563%2Epng)

![](https://maker.wiznet.io/upload/ckeditor5/57019074%5F1707230417%2Epng)

- Enter Surf 5 into boot mode and search for Surf 5's serial port, then press '**Open**'.

![](https://maker.wiznet.io/upload/ckeditor5/57018711%5F1707211821%2Epng)

- If the connection to the tool is successful, a successful connection message will appear as below.

![](https://maker.wiznet.io/upload/ckeditor5/57018711%5F1707211899%2Epng)

- Press the** 'Start All Steps'** button to start flashing.

![](https://maker.wiznet.io/upload/ckeditor5/57018711%5F1707211947%2Epng)

- Open the Hercules program to set client mode **[IP Address]** and **[PORT number]** and Connect to the Server.

![](https://hackster.imgix.net/uploads/attachments/1557096/loopback_server_2_FPK9iRviAQ.png?auto=compress%2Cformat&w=740&h=555&fit=max)

- If you send the phrase Loopback Test, you can see that you are sending and receiving data.

![](https://hackster.imgix.net/uploads/attachments/1557097/loopback_server_3_RHNIRhDPoP.png?auto=compress%2Cformat&w=740&h=555&fit=max)

---

Source: https://maker.wiznet.io/TheoIm/projects/surf-5-loopback-server-example-in-keil-5/
