Yuqiang Wang e1498cabc9 SDK build (#47) 5 月之前
..
.settings 4795f3d206 更新fsp为2.2.0 6 月之前
board 64ec089d19 [HAL_Drivers]新增CAN和CANFD切换的宏 9 月之前
figures eef1e05537 Improve engineering documentation and upload user manual 1 年之前
packages 1be3279675 upload project(irq、modbus、mqtt...) 1 年之前
rzn 0e9a0dfdbd fix iar link source 6 月之前
rzn_cfg 0e9a0dfdbd fix iar link source 6 月之前
rzn_gen 0e9a0dfdbd fix iar link source 6 月之前
script 4795f3d206 更新fsp为2.2.0 6 月之前
src 4795f3d206 更新fsp为2.2.0 6 月之前
.api_xml 1be3279675 upload project(irq、modbus、mqtt...) 1 年之前
.config 4795f3d206 更新fsp为2.2.0 6 月之前
.cproject 4795f3d206 更新fsp为2.2.0 6 月之前
.gitignore 43669c1c97 Fixed some known issues 1 年之前
.project 1be3279675 upload project(irq、modbus、mqtt...) 1 年之前
.secure_azone 1be3279675 upload project(irq、modbus、mqtt...) 1 年之前
.secure_rzone 4795f3d206 更新fsp为2.2.0 6 月之前
.secure_xml 4795f3d206 更新fsp为2.2.0 6 月之前
Kconfig 4795f3d206 更新fsp为2.2.0 6 月之前
README.md e1498cabc9 SDK build (#47) 5 月之前
README_zh.md e1498cabc9 SDK build (#47) 5 月之前
SConscript 0e9a0dfdbd fix iar link source 6 月之前
SConstruct 1be3279675 upload project(irq、modbus、mqtt...) 1 年之前
buildinfo.ipcf 0e9a0dfdbd fix iar link source 6 月之前
buildinfo.json 4795f3d206 更新fsp为2.2.0 6 月之前
configuration.xml 4795f3d206 更新fsp为2.2.0 6 月之前
envsetup.sh 1be3279675 upload project(irq、modbus、mqtt...) 1 年之前
mklinks.bat 1be3279675 upload project(irq、modbus、mqtt...) 1 年之前
mklinks.sh 1be3279675 upload project(irq、modbus、mqtt...) 1 年之前
ozone_scons.jdebug 384e7a31df 修复scons固件无法运行的问题,添加ozone调试脚本 1 年之前
project.ewd 0e9a0dfdbd fix iar link source 6 月之前
project.ewp 0e9a0dfdbd fix iar link source 6 月之前
project.ewt 0e9a0dfdbd fix iar link source 6 月之前
project.eww 1be3279675 upload project(irq、modbus、mqtt...) 1 年之前
rtconfig.h 4795f3d206 更新fsp为2.2.0 6 月之前
rtconfig.py 384e7a31df 修复scons固件无法运行的问题,添加ozone调试脚本 1 年之前
rzn_cfg.txt 4795f3d206 更新fsp为2.2.0 6 月之前
template.ewd 0e9a0dfdbd fix iar link source 6 月之前
template.ewp 0e9a0dfdbd fix iar link source 6 月之前
template.eww 1be3279675 upload project(irq、modbus、mqtt...) 1 年之前

README.md

Modbus-TCP/IP Usage Instructions

English | 中文

Introduction

This example is based on the agile_modbus package and demonstrates Modbus protocol communication over TCP/IP.

Hardware Requirements

image-20241126110356394

FSP Configuration Instructions

  • Open the project configuration file configuration.xml:

image-20241126110921803

  • Add the r_gamc stack:

image-20241126110942044

  • Click on g_ether0 Ethernet and configure the interrupt callback function as user_ether0_callback:

image-20241126110959958

  • Next, configure the PHY information. Select g_ether_phy0, set the Common configuration to "User Own Target," change the PHY LSI address to 1 (refer to the schematic for the exact address), and set the PHY initialization callback function to ether_phy_targets_initialize_rtl8211_rgmii(). Also, set MDIO to GMAC.

image-20241126111030094

  • Configure g_ether_selector0, set the Ethernet mode to Switch mode, set the PHY link to default active-low, and configure the PHY interface mode to RGMII.

image-20241126111045618

Configure the network card pin parameters, setting the operation mode to RGMII:

image-20241126111056497

  • ETHER_GMAC configuration:

image-20241126111108626

RT-Thread Settings Configuration

Return to the Studio project, configure RT-Thread Settings, select hardware options, and enable Ethernet by finding the chip device driver:

image-20241126111138462

In the software package interface, search for "modbus," select the agile_modbus package, and enable it:

image-20241126111206558

Compilation & Download

  • RT-Thread Studio: Download the EtherKit resource package in the RT-Thread Studio package manager, create a new project, and compile it.
  • IAR: First, double-click mklinks.bat to create the link between the rt-thread and libraries folders. Then, use Env to generate the IAR project. Finally, double-click project.eww to open the IAR project and compile it.

Once the compilation is complete, connect the Jlink interface of the development board to the PC and download the firmware to the board.

Running Results

First, use an Ethernet cable to connect the development board's network port to a switch (if your computer has an extra Ethernet port, you can also use a shared adapter). Then, enter the command modbus_tcp_test in the serial tool to start the Modbus-TCP example:

image-20241126111241084

Open the Modbus Poll software, connect to the development board, set the mode to Modbus TCP/IP, set the IP to the development board's IP address, and the port number to 502:

image-20241126111250484

After a successful connection, the development board's terminal will display that the Modbus client is connected:

image-20241126111259367

Return to the Modbus Poll software, and you will see that the read and write coil functions are working correctly:

image-20241126111311175