Yuqiang Wang e1498cabc9 SDK build (#47) 5 месяцев назад
..
.settings 4795f3d206 更新fsp为2.2.0 6 месяцев назад
board 4795f3d206 更新fsp为2.2.0 6 месяцев назад
figures eef1e05537 Improve engineering documentation and upload user manual 1 год назад
packages 4795f3d206 更新fsp为2.2.0 6 месяцев назад
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 1be3279675 upload project(irq、modbus、mqtt...) 1 год назад
.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-UART Usage Instructions

English | 中文

Introduction

This example is based on the agile_modbus package and demonstrates Modbus protocol communication over UART. Modbus UART is a version of the Modbus protocol implemented via serial communication and is widely used in industrial automation and control systems. Modbus is an open communication protocol used to transfer data between control devices and supports multiple physical layers such as UART, TCP/IP, and RS-485/232.

Hardware Requirements

image-20241126105924215

As shown in the image above, the peripheral used in this example is the SCI module. SCI3 is configured in UART mode, with TX pin as P18_0 and RX pin as P17_7.

FSP Configuration Instructions

Open the configuration.xml file in the project and add a new stack:

image-20241126105954365

Enable the r_sci_uart configuration and support FIFO. Set the channel number to 3:

image-20241126110007987

Click on Pins, configure SCI3, and set the SCI mode to Asynchronous mode. The corresponding pins will be enabled accordingly:

image-20241126110018927

Return to the stack configuration page, expand and set the interrupt callback function to user_uart3_callback. The corresponding UART pin information will be shown below:

image-20241126110028462

RT-Thread Settings Configuration

Back in RT-Thread Studio, go to RT-Thread Settings, enable UART3 for the serial port configuration:

image-20241126110052239

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

image-20241126110101998

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, you need a USB-to-TTL module. Connect the TX and RX pins of the USB-to-TTL module to the RX and TX pins (P18_0 and P17_7) of the development board, respectively, as shown below:

image-20241126110136703

Next, open the Modbus Slave software and click Connect:

image-20241126110148129

Configure the Modbus Slave settings. Select Serial Mode for the connection type, choose the USB-to-TTL module connected to the development board, and set None Parity:

image-20241126110158100

Then, return to the serial terminal and enter the command modbus_master_uart_sample to start the Modbus master example:

image-20241126110208170

The development board's UART3 functions as the master, and the PC acts as the slave. The master writes to the coil at the station number, and the terminal will display the updated registers:

image-20241126110221649