|
|
5 месяцев назад | |
|---|---|---|
| .. | ||
| .settings | 6 месяцев назад | |
| board | 8 месяцев назад | |
| figures | 1 год назад | |
| packages | 1 год назад | |
| rzn | 6 месяцев назад | |
| rzn_cfg | 6 месяцев назад | |
| rzn_gen | 6 месяцев назад | |
| script | 6 месяцев назад | |
| src | 6 месяцев назад | |
| .api_xml | 1 год назад | |
| .config | 6 месяцев назад | |
| .cproject | 6 месяцев назад | |
| .gitignore | 1 год назад | |
| .project | 1 год назад | |
| .secure_azone | 1 год назад | |
| .secure_rzone | 6 месяцев назад | |
| .secure_xml | 6 месяцев назад | |
| Kconfig | 6 месяцев назад | |
| README.md | 5 месяцев назад | |
| README_zh.md | 5 месяцев назад | |
| SConscript | 6 месяцев назад | |
| SConstruct | 1 год назад | |
| buildinfo.ipcf | 6 месяцев назад | |
| buildinfo.json | 6 месяцев назад | |
| configuration.xml | 6 месяцев назад | |
| envsetup.sh | 1 год назад | |
| mklinks.bat | 1 год назад | |
| mklinks.sh | 1 год назад | |
| ozone_scons.jdebug | 1 год назад | |
| project.ewd | 6 месяцев назад | |
| project.ewp | 6 месяцев назад | |
| project.ewt | 6 месяцев назад | |
| project.eww | 1 год назад | |
| rtconfig.h | 6 месяцев назад | |
| rtconfig.py | 1 год назад | |
| rzn_cfg.txt | 6 месяцев назад | |
| template.ewd | 6 месяцев назад | |
| template.ewp | 6 месяцев назад | |
| template.eww | 1 год назад | |
English | 中文
This example is based on the agile_modbus package and demonstrates Modbus protocol communication over TCP/IP.
configuration.xml:r_gamc stack:g_ether0 Ethernet and configure the interrupt callback function as user_ether0_callback: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.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.Configure the network card pin parameters, setting the operation mode to RGMII:
Return to the Studio project, configure RT-Thread Settings, select hardware options, and enable Ethernet by finding the chip device driver:
In the software package interface, search for "modbus," select the agile_modbus package, and enable it:
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.
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:
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:
After a successful connection, the development board's terminal will display that the Modbus client is connected:
Return to the Modbus Poll software, and you will see that the read and write coil functions are working correctly: