Surf 5 - Loopback server example in VS Code
Surf 5 - Loopback server example
This project builds the Loopback example of Surf 5 in VS Code. 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.
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 VS Code and open the Surf 5 library project. If you created a workspace in 'How to make Projects in VS Code', it is recommended to open the workspace.
- After pressing the 'F7' button, check if the build is successful as indicated by the red square box below. If the build fails, return to 'How to make Projects in VS Code' and reconfigure the environment to ensure the build is successful.
- Navigate to 'Projects\W7500x_StdPeriph_Examples\WZTOE\WZTOE_Loopback\main.c' as shown below.
- In the 'Network_Config' function in main.c of the 'WZTOE_Loopback' project, 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;
}
- If you have configured the network code to match your environment, press the build button below to rebuild.
Step 4: Upload and Run
Loopback Server Mode
- Please turn on the 'W7500 ISP Tool' for flashing.
- Click the 'Browse' button in Step 5 of the tool. Then, select WZTOE_Loopback.bin located in the '...\W7500x-Surf5\build\Projects\W7500x_StdPeriph_Examples\WZTOE\WZTOE_Loopback path'.
- Enter Surf 5 into boot mode and search for Surf 5's serial port, then press 'Open'.
- If the connection to the tool is successful, a successful connection message will appear as below.
- Press the 'Start All Steps' button to start flashing.
- Open the Hercules program to set client mode [IP Address] and [PORT number] and Connect to the Server.
- If you send the phrase Loopback Test, you can see that you are sending and receiving data.