Yuqiang Wang e1498cabc9 SDK build (#47) 5 месяцев назад
..
.settings 4795f3d206 更新fsp为2.2.0 6 месяцев назад
board 64ec089d19 [HAL_Drivers]新增CAN和CANFD切换的宏 8 месяцев назад
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