731 views|0 replies

28

Posts

3

Resources
The OP
 

[Digi-Key Follow me Issue 4] Basic Task 1: Complete the initialization of the main control board W5500 (static IP configuration) [Copy link]

  This post was last edited by 鲜de芒果 on 2024-2-22 12:19

2.1 Mission Statement

Complete the initialization of the main control board W5500 (static IP configuration), and be able to use the LAN computer to ping, and W5500 can ping Internet sites; use packet capture software (Wireshark, Sniffer, etc.) to capture the local PC's ping message, display and analyze it.

2.2 Code Implementation

import time
import board
import busio
import asyncio
import digitalio
from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K

# 网口 SPI 引脚定义
SPI0_SCK = board.GP18
SPI0_TX = board.GP19
SPI0_RX = board.GP16
SPI0_CSn = board.GP17
# RESET 引脚定义
W5x00_RSTn = board.GP20

print("Wiznet5k Ping Test (no DHCP)")

# 静态IP设置
# MAC地址
MAC = (0x00, 0x01, 0x02, 0x03, 0x04, 0x05)
# IP地址
IP_ADDRESS = (192, 168, 1, 101)
# 子网掩码
SUBNET_MASK = (255, 255, 255, 0)
# 网关
GATEWAY_ADDRESS = (192, 168, 1, 1)
# DNS
DNS_SERVER = (8, 8, 8, 8)
# 网络接口对象
eth = None 

''' 网络初始化 '''
async def init():
    global eth
    # REST引脚初始化
    rst_pin = digitalio.DigitalInOut(W5x00_RSTn)
    rst_pin.direction = digitalio.Direction.OUTPUT

    # SPI CS引脚初始化
    cs = digitalio.DigitalInOut(SPI0_CSn)
    # SPI初始化
    spi_bus = busio.SPI(SPI0_SCK, MOSI=SPI0_TX, MISO=SPI0_RX)

    # 官网示例先重置 W5500
    rst_pin.value = False
    time.sleep(1)
    rst_pin.value = True

    # 网口初始化
    eth = WIZNET5K(spi_bus, cs, is_dhcp=False, mac=MAC)

    # 配置网络
    eth.ifconfig = (IP_ADDRESS, SUBNET_MASK, GATEWAY_ADDRESS, DNS_SERVER)

    print("芯片版本:", eth.chip)
    print("MAC地址:", [hex(i) for i in eth.mac_address])
    print("IP地址:", eth.pretty_ip(eth.ip_address))
    print("请求电子工程世界IP地址: %s" % eth.pretty_ip(eth.get_host_by_name("www.eeworld.com.cn")))
    while True:
        await asyncio.sleep_ms(1)

2.3 Effect Display

From the screenshot of Wireshark , when the computer PINGs the IP of the development board, there are request and response packets, as shown in the figure above. Please see the attached file for the packet capture file. From the console in the screenshot, we can see that when requesting the IP address from the Electronic Engineering World website, we get a response and print out the real IP address of the Electronic Engineering World website, which is consistent with the IP address obtained by the computer terminal PINGing the Electronic Engineering World .

2.4 Summary

After the CircuitPython development environment of W5500-EVB-Pico is installed, load the w5500 driver library, and you can easily achieve network access, which is very convenient and friendly. However, the library currently does not support SocketPool very well, which makes it difficult to use in some occasions.

2.5 Video Demonstration


2.6 Capture file

ping-test.pcapng (1.87 MB, downloads: 0)



This post is from DigiKey Technology Zone
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
ST MEMS sensor official Chinese technical documentation summary (continuously updated)

Netizens who are interested in ST MEMS sensors or use sensors are welcome to gather in the "ST Sensor and Wireless Commu ...

Could you please help me see how to filter this switching power supply circuit?

As the title says, the ACDC switching power supply outputs 5V voltage through LDO. How to filter it next? Below is the ...

How to make an overvoltage protection circuit?

The maximum input voltage of the board is 60V. How can I disconnect it when it exceeds 60V? I used a self-resettable fus ...

We spent 2 days to make a small 104 capacitor

I haven't posted in EE for a long time, which is really embarrassing. The main reason is that I am getting further a ...

Evaluation and Award: ST New Product NUCLEO-L552ZE-Q (Cortex-M33)

Event details: Click here to view Thanks to the netizens for sharing the review content of NUCLEO-L552ZE. The following ...

[Development and application based on NUCLEO-F746ZG motor] 12. Parameter configuration - timer TIM1 configuration

In the process of controlling the servo motor, in order to make the motor rotate as you want, PWM output control must b ...

Please tell me why this machine often burns the starting resistor at the customer's place

Please tell me why the resistor burned out and how to fix it? 627875627874627873

USB-C PD power receiving end power induction power receiving multi-protocol chip LDR6328S

Preface USB PD is currently the mainstream fast charging protocol. With the release of USB PD3.1, the transmission power ...

esp32 Help...

Hey guys, I have a problem that bothers me. The circuit is that esp32 measures the resistance, capacitance and impedance ...

I was working on my phone until 1am in the middle of the night, and this is how I solved it....

The thing is, at about 12 o'clock last night, the volume interface of my mobile phone kept popping up, which was very an ...

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list