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

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