DG0440: Running Modbus TCP Reference Design on SmartFusion2 Devices using IwIP and FreeRTOS - Libero SoC v11.7 Demo Guide

Running Modbus TCP Reference Design on
SmartFusion2 Devices using IwIP and
FreeRTOS - Libero SoC v11.7
DG0440 Demo Guide
Contents
1 Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1
1.2
1.3
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Intended Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3.1
Microsemi Publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3.2
Others . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3.2.1
Modbus Protocol Quick References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and FreeRTOS
..................................................................6
2.1
2.2
2.3
2.4
2.5
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.1
Using the Modbus Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.2
Using Modbus Protocol on SmartFusion2 Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Design Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Demo Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3.1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3.2
Demo Design Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3.3
Demo Design Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3.3.1
Libero SoC Hardware Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3.3.2
SoftConsole Firmware Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Setting Up the Demo Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.4.1
Board Setup Snapshot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Running the Demo Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.5.1
Running Modbus Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5.1.1
Read Discrete Inputs (function code 02) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5.1.2
Read Holding Registers (function code 03) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5.1.3
Read Input Registers (function code 04) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5.1.4
Write Multiple Coils (function code 0×0F) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3 Appendix: Board Setup for Running the Modbus TCP Reference Design . . . . . . . 23
4 Appendix: Jumper Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5 Appendix: Running the Design in Static IP Mode . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6 Revision History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
7 Product Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
7.1
7.2
7.3
7.4
7.5
7.6
Customer Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Customer Technical Support Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Website . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contacting the Customer Technical Support Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.5.1
Email . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.5.2
My Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.5.3
Outside the U.S. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ITAR Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Revision 5
30
30
30
30
30
30
30
31
31
2
Figures
Figure: 1
Figure: 2
Figure: 3
Figure: 4
Figure: 5
Figure: 6
Figure: 7
Figure: 8
Figure: 9
Figure: 10
Figure: 11
Figure: 12
Figure: 13
Figure: 14
Figure: 15
Figure: 16
Figure: 17
Figure: 18
Figure: 19
Figure: 20
Figure: 21
Figure: 22
Figure: 23
Modbus Communication Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Block Diagram of Modbus TCP Server and Application on SmartFusion2 . . . . . . . . . . . . . . . . . . . . 8
Demo Design Files Top-Level Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Libero Top-Level Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
High Speed Serial Interface Configurator Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
SoftConsole Project Explorer Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Device Manager Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
FlashPro New Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
FlashPro Project Configured . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
FlashPro Program Passed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
HyperTerminal with IP Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Invoking the Modbus Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Modbus Functional Codes Demonstration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Read Discrete Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Read Holding Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Read Input Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Write Multiple Coils . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
SmartFusion2 Advanced Development Kit Board Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
SmartFusion2 Advanced Development Kit Silkscreen Top View . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Project Explorer Window of SoftConsole Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Project Explorer Properties Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Host PC TCP/IP Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Static IP Address Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Revision 5
3
Tables
Table 1:
Table 2:
Table 3:
Table 4:
Table 5:
Table 6:
Reference Design Requirements and Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
LED to Package Pins Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
DIP Switches to Package Pins Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Push Button Switches to Package Pins Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
PHY Interface Signals to Package Pins Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
SmartFusion2 Advanced Development Kit Jumper Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Revision 5
4
Preface
1
Preface
1.1
Purpose
This demo is for SmartFusion®2 system-on-chip (SoC) field programmable gate array (FPGA) devices. It
provides instructions on how to use the corresponding reference design.
1.2
Intended Audience
This demo guide is intended for:
•
•
•
1.3
FPGA designers
Embedded designers
System-level designers
References
The following documents are referred in this demo guide.
1.3.1
Microsemi Publications
•
•
•
•
1.3.2
UG0331: SmartFusion2 Microcontroller Subsystem User Guide
UG0447: IGLOO2 FPGA and SmartFusion2 SoC FPGA High Speed Serial Interfaces User Guide
Libero SoC User Guide
UG0557: SmartFusion2 SoC FPGA Advanced Development Kit User Guide
Refer to the following web page for a complete and up-to-date listing of SmartFusion2 device documentation: http://www.microsemi.com/products/fpga-soc/soc-fpga/sf2docs.
Others
1.3.2.1 Modbus Protocol Quick References
•
•
•
•
•
•
The Modbus TCP implementation guidelines can be found in the
Modbus Messaging on TCP/IP Implementation Guide v1.0b.
The Modbus protocol source code used for the design example in this document is from
www.freemodbus.org with updates for the complete set of features of the Modbus layer.
Modbus Organization: www.modbus.org
•
FAQ: www.modbus.org/faq.php
•
Technical resources including specifications and links to free and commercial Modbus tools and
resources: www.modbus.org/tech.php
Wikipedia page on Modbus: http://en.wikipedia.org/wiki/Modbus
FreeModbus home page: www.freemodbus.berlios.de/
•
API Documentation: www.freemodbus.berlios.de/api/index.html
•
Examples using Modpoll: www.freemodbus.berlios.de/index.php?idx=1
FreeRTOS™ stack: www.freeRTOS.org
Revision 5
5
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
2
Running Modbus TCP Reference Design on
SmartFusion2 Using IwIP and FreeRTOS
2.1
Introduction
Microsemi offers a reference design for SmartFusion2 SoC FPGA devices that demonstrates the
tri-speed ethernet medium access controller (TSEMAC) features of the SmartFusion2 SoC FPGA and
implements the Modbus Protocol. The reference design runs on the SmartFusion2 Advanced
Development Kit. This demo guide describes:
•
•
•
•
Usage of SmartFusion2 TSEMAC connected to a serial gigabit media independent interface (SGMII)
PHY.
Integration of SmartFusion2 MAC driver with the lwIP TCP or IP stack and the FreeRTOS Operating
System.
Application layer with industrial automation protocol, Modbus on TCP or IP.
How to run the reference design
The microcontroller subsystem (MSS) of the SmartFusion2 SoC FPGA has an instance of the TSEMAC
peripheral. The TSEMAC can be configured between the host processor and the Ethernet network at the
following data transfer rates (line speeds):
•
•
•
10 Mbps
100 Mbps
1000 Mbps
Refer to the UG0331: SmartFusion2 Microcontroller Subsystem User Guide for more information on the
TSEMAC interface for SmartFusion2 devices.
2.1.1
Using the Modbus Protocol
Modbus is an application layer messaging protocol present at the level seven of the open systems
interconnection (OSI) model. It enables client or server communication between the devices connected
in different types of buses or networks. It is a service protocol that offers many services specified by the
function codes. The Modbus function codes are elements of Modbus request or reply protocol data units.
The components of the Modbus protocol include:
•
•
•
TCP or IP over Ethernet
Asynchronous serial transmission over a variety of media
•
Wire
•
EIA/TIA-232-E
•
EIA-422
•
EIA/TIA-485-A
•
Fiber
•
Radio
Modbus PLUS, a high-speed token passing network
Revision 5
6
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
Figure 1 describes the Modbus communication stacks for various communication networks.
Figure 1 • Modbus Communication Stack
Modbus Application Layer
Modbus on TCP
TCP
IP
Other
Modbus/HDLC
Master/Slave
Ethernet II/802.3
Other
Physical Layer
EIA/TIA-232 or
EIA/TIA-485
Ethernet Physical
Layer
For more information on Modbus protocol, refer to the "Modbus Protocol Quick References" on page 5.
Revision 5
7
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
2.1.2
Using Modbus Protocol on SmartFusion2 Device
The Modbus TCP Server runs on the SmartFusion2 Advanced Development Kit and responds to the
Modbus TCP client running on the host PC. Figure 2 shows the block diagram of Modbus TCP Server
and application on the SmartFusion2 device.
Figure 2 • Block Diagram of Modbus TCP Server and Application on SmartFusion2
0RGEXV7&36HUYHU
0RGEXV7&3$SSOLFDWLRQ
,Z,37&3RU,36WDFN
)UHH5726
)LUPZDUH
6PDUW)XVLRQ$GYDQFHG'HYHORSPHQW.LW+:
Revision 5
8
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
2.2
Design Requirements
Table 1 lists the hardware and software design requirements.
Table 1 • Reference Design Requirements and Details
Reference Design Requirements and Details
Description
Hardware Requirements
SmartFusion2 Advanced Development Kit
• USB A to mini-B cable
• 12 V adapter
Rev B or later
RJ45 cable
–
Any one of the following serial terminal emulation
programs:
• HyperTerminal
• TeraTerm
• PuTTY
–
Host PC or Laptop
Any 64-bit Windows Operating System
Software Requirements
Libero® System-on-Chip (SoC)
v11.7
SoftConsole
v3.4 SP1*
FlashPro programming software
v11.7
USB to UART drivers
–
Note: *For this demo guide, SoftConsole v3.4 SP1 is used. For using SoftConsole v4.0, see the
TU0546: SoftConsole v4.0 and Libero SoC v11.7 Tutorial.
2.3
Demo Design
2.3.1
Introduction
The reference design files are available for download from the Microsemi website:
http://soc.microsemi.com/download/rsc/?f=m2s_dg0440_liberov11p7_df
The demo design files include:
•
•
•
•
Libero
Programming files
HostTool
Readme
Revision 5
9
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
Figure 3 shows the top-level structure of the design files. For further details, refer to the readme.txt
file.
Figure 3 • Demo Design Files Top-Level Structure
PVBGJBOLEHURYSBGI
6)B0RGEXVB7&3B5HIB'HVLJQB')
+RVW7RRO
/LEHUR
3URJUDPPLQJILOH
5HDGPH
2.3.2
Demo Design Features
The reference design includes:
•
•
Complete Libero SoC Verilog project
SoftConsole firmware project
The reference design can support the following Modbus function codes depending on the free Modbus
communications stack settings:
•
•
•
•
•
•
•
•
•
Read input registers (function code 0×04)
Read holding registers (function code 0×03)
Write single registers (function code 0×06)
Write multiple registers (function code 0×10)
Read or Write multiple registers (function code 0×17)
Read coils (function code 0×01)
Write single coil (function code 0×05)
Write multiple coils (function code 0×0F)
Read discrete inputs (function code (0×02)
The reference design supports the following Modbus function codes for all Free Modbus communications
stack settings:
•
•
•
•
Read input registers (function code 0×04)
Read discrete inputs (function code (0×02)
Write multiple coils (function code 0×0F)
Read holding registers (function code 0×03)
Revision 5
10
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
2.3.3
Demo Design Description
The design is implemented using a SGMII PHY interface by configuring the TSEMAC for the ten-bit
interface (TBI) operation. For more information on the TSEMAC TBI interface, refer to the
UG0331: SmartFusion2 Microcontroller Subsystem User Guide.
The design comprises:
•
•
Libero SoC Hardware Project
SoftConsole Firmware Project
2.3.3.1 Libero SoC Hardware Project
Figure 4 shows the hardware design implementation on which the reference design slave firmware runs.
Figure 4 • Libero Top-Level Design
Revision 5
11
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
Libero hardware project uses the following SmartFusion2 MSS resources and IPs:
•
•
•
•
•
TSEMAC TBI interface
MMUART_0 for RS-232 communications on the SmartFusion2 Advanced Development Kit
General purpose input and output (GPIO) that interfaces the following:
•
Light emitting diodes (LEDs): 4 numbers
•
Push-buttons: 4 numbers
•
DIP switches: 4 numbers
The following board resources are associated with the Modbus commands:
•
LEDs (coils)
•
DIP switches (discrete inputs)
•
Push-buttons (discrete inputs)
•
RTC (input registers)
High-speed serial interface (SERDESIF) SERDES_IF IP, configured for
SERDESIF_3 EPCS lane 3, refer to Figure 5. To know more about high-speed serial interfaces,
refer to the UG0447- SmartFusion2 and IGLOO2 FPGA High Speed Serial Interfaces User Guide .
Figure 5 shows the High Speed Serial Interface Configurator window.
Figure 5 • High Speed Serial Interface Configurator Window
Revision 5
12
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
2.3.3.1.1 Package Pin Assignments
Package pin assignments for LED, DIP switches, push-button switches, and PHY interface signals are
shown in Table 2 through Table 5.
Table 2 • LED to Package Pins Assignments
Output
Package Pin
LED_1
D26
LED_2
F26
LED_3
A27
LED_4
C26
Table 3 • DIP Switches to Package Pins Assignments
Output
Package Pin
DIP1
F25
DIP2
G25
DIP3
J23
DIP4
J22
Table 4 • Push Button Switches to Package Pins Assignments
Output
Package Pin
SWITCH1
J25
SWITCH2
H25
SWITCH3
J24
SWITCH4
H23
Table 5 • PHY Interface Signals to Package Pins Assignments
Port Name
Direction
Package Pin
PHY_MDC
Output
F3
PHY_MDIO
Input
K7
PHY_RST
Output
F2
2.3.3.2 SoftConsole Firmware Project
Invoke the SoftConsole project using Standalone SoftConsole IDE.
The following versions of the stack are used for the reference design:
•
•
•
lwIP TCP or IP stack version 1.3.2
Modbus TCP server version 1.5 (www.freemodbus.org) with enhancements for the complete
function code support as Modbus TCP server
FreeRTOS (www.freertos.org)
Revision 5
13
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
Figure 2 on page 8 shows the block diagram of the Modbus TCP Server and application on
SmartFusion2 used in this design.
Figure 6 shows SoftConsole software stacks directory structure of the design.
Figure 6 • SoftConsole Project Explorer Window
Revision 5
14
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
2.4
Setting Up the Demo Design
The following steps describe how to setup the demo for SmartFusion2 Advanced Development Kit board:
1.
2.
3.
4.
Connect the host PC to the J33 connector using the USB A to mini-B cable. The USB to UART
bridge drivers are automatically detected.
From the detected four COM ports, right-click any one of the COM ports and select Properties. The
selected COM port properties window is displayed, as shown in Figure 7.
Ensure to have the Location as on USB FP5 Serial Converter C in the Properties window as
shown in Figure 7.
Make a note of the COM port number for serial port configuration and ensure that the COM port
Location is specified as on USB FP5 Serial Converter C.
Figure 7 • Device Manager Window
5.
6.
Install the USB driver if the USB drivers are not detected automatically.
Install the FTDI D2XX driver for serial terminal communication through the FTDI mini USB cable.
Download the drivers and installation guide from:
www.microsemi.com/soc/documents/CDM_2.08.24_WHQL_Certified.zip
Revision 5
15
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
7.
Connect the jumpers on the SmartFusion2 Advanced Development Kit board as shown in Table 6.
For information on jumper locations, refer to "Appendix: Jumper Locations" on page 24.
CAUTION: Switch OFF the power supply switch SW7, before making the jumper connections.
Table 6 • SmartFusion2 Advanced Development Kit Jumper Settings
Jumper
Pin (from)
Pin (to)
Comments
J116, J353, J354,J54
1
2
J123
2
3
These are the default jumper settings of the Advanced
Development Kit board. Ensure that jumpers are set
accordingly.
J124, J121, J32
1
2
8.
9.
2.4.1
JTAG programming via FTDI
Connect the power supply to the J42 connector in the SmartFusion2 Advanced Development Kit
board.
This design example can run in both Static IP and Dynamic IP modes. By default, programming files
are provided for dynamic IP mode.
•
For static IP, connect the host PC to the J21 connector of the SmartFusion2 Advanced
Development Kit board using an RJ45 cable.
•
For dynamic IP, connect any one of the open network ports to the J21 connector of the
SmartFusion2 Advanced Development Kit board using an RJ45 cable.
Board Setup Snapshot
Snapshots of the SmartFusion2 Advanced Development Kit board with all the setup connections are
given in the following "Appendix: Board Setup for Running the Modbus TCP Reference Design" on
page 23
2.5
Running the Demo Design
The following steps describe how to run the demo design:
1.
Download the design file from:
http://soc.microsemi.com/download/rsc/?f=m2s_dg0440_liberov11p7_df
2. Switch ON the SW7 power supply switch.
3. Start any serial terminal emulation program such as:
•
HyperTerminal
•
PuTTY
•
TeraTerm
Note: In this demo HyperTerminal is used.
The configuration for the program is:
•
Baud Rate: 115200
•
8 Data bits
•
1 Stop bit
•
No parity
•
No flow control
For information on configuring the serial terminal emulation programs, refer to the
Configuring Serial Terminal Emulation Programs.
4.
5.
6.
Launch the FlashPro software.
Click New Project.
In the New Project window, enter the Project Name.
Revision 5
16
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
Figure 8 • FlashPro New Project
7.
8.
9.
10.
11.
Click Browse and navigate to the location where you want to save the project.
Select Single device as the Programming mode.
Click OK to save the project.
Click Configure Device.
Click Browse and navigate to the location where the Modbus_TCP_top.stp file is located and
select the file. The default location is:
(\SF2_Modbus_TCP_Ref_Design_DF\Programmingfile\Modbus_TCP_top.stp). The required
programming file is selected and is ready to be programmed in the device.
Revision 5
17
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
Figure 9 • FlashPro Project Configured
Revision 5
18
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
12. Click PROGRAM to start programming the device. Wait until a message is displayed indicating that
the program passed. This demo requires the SmartFusion2 device to be preprogrammed with the
application code to activate the Modbus application. The SmartFusion2 device is preprogrammed
with the Modbus_TCP_top.stp using FlashPro software.
Figure 10 • FlashPro Program Passed
Note: To run the design in Static IP mode, follow the steps mentioned in "Appendix: Running the Design in
Static IP Mode" on page 25.
13. Power cycle the SmartFusion2 Advanced Development board.
Revision 5
19
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
A welcome message with the IP address is displayed in the HyperTerminal window, as shown in
Figure 11.
Figure 11 • HyperTerminal with IP Address
14. Open a new command prompt on the host PC, go to the folder
(\SF2_Modbus_TCP_Ref_Design_DF\HostTool) where SmartFusion2_Modbus_TCP_Client.exe
file is present, enter the command:
SmartFusion2_Modbus_TCP_Client.exe <IP address>
Figure 12 • Invoking the Modbus Client
Revision 5
20
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
Figure 13 shows the Modbus TCP functions that are running. The functions are:
•
•
•
•
Read discrete inputs (function code 02)
Read holding registers (function code 03)
Read input registers (function code 04)
Write multiple coils (function code 15)
Figure 13 • Modbus Functional Codes Demonstration
Refer to the "Running Modbus Functions" on page 22 for more information on the Modbus functions
that are demonstrated in the reference design.
15. After running the demo, close HyperTerminal.
Revision 5
21
Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and
FreeRTOS
2.5.1
Running Modbus Functions
This section describes the Modbus functions that are demonstrated in the reference design.
2.5.1.1 Read Discrete Inputs (function code 02)
GPIOs are connected to 4 DIP switches and 4 push-button switches. Switch ON and switch OFF the DIP
switches and push-button switches on the SmartFusion2 Advanced Development Kit. Read discrete
inputs functional code displays the statuses of switches as shown in Figure 14.
Figure 14 • Read Discrete Inputs
2.5.1.2 Read Holding Registers (function code 03)
Figure 15 shows the global buffer data defined in the firmware.
Figure 15 • Read Holding Registers
2.5.1.3 Read Input Registers (function code 04)
Figure 16 shows the number of seconds that the real-time counter (RTC) has counted.
Figure 16 • Read Input Registers
2.5.1.4 Write Multiple Coils (function code 0×0F)
Figure 17 shows the Write Multiple Coils register data for toggling the LEDs connected to GPIOs.
Figure 17 • Write Multiple Coils
Revision 5
22
Appendix: Board Setup for Running the Modbus TCP Reference Design
3
Appendix: Board Setup for Running the
Modbus TCP Reference Design
Figure 18 shows the board setup for running the reference design on the SmartFusion2 Advanced
Development Kit board.
Figure 18 • SmartFusion2 Advanced Development Kit Board Setup
Push button
switches
RJ45-Cable
LEDs
Push button
switch
DC Jack
to connect
12 V Adapter
DIP
switches
USB Mini-B
Connector
Power supply
switch SW7
SW6 to reset
Revision 5
23
Appendix: Jumper Locations
4
Appendix: Jumper Locations
Figure 19 shows the jumper locations on the SmartFusion2 Advanced Development Kit board.
Figure 19 • SmartFusion2 Advanced Development Kit Silkscreen Top View
3
2
1
R369
DS19
DS20
C604
J121
J124
DS0
R253
9
J32
J60
19
2
20
J38
1
19
R162
R330 C596
R260
U34
U23
C1
H1
R255
C600
C332
U25
TP3
TP7 TP20
R155
TP4
R283
R282
C697 C696
J123
J29
R279
R278
R276
U31
R161
J28
C638
R304
D7
H40
10
J37
20
C610
SW4
B
C40
1
J36
SW3
A
U24
SW1
2
J125
DS1
DS2
SW2
TP16
R267 DS16
R151 R147
R364
R318
R362
Y11
TP12
J351
D9
C593
2
H1
DS21
U59
J119
B
R306
C636
R305
C637
TP21
TP9
D8
R148
1
DS3
DS5
DS4
B
A
R366
R152
3
DS29
R354
R1216
R1217
8
6
5
4
R159
R158
R316
R220
R222
R224
A
U35
TP10 TP22
U32
C647
R310
DS18
1
R272
C608
R149
C328
U13
R363 R361
C467
C460
C455
DS6
DS7
C119
C161
C233
C197
C118
C163
C562
R150
TP68
TP41
Y12
R314
C109
C150
C236
C235
C199
C159
C116
C465
U5
R338
R277
C698
U3
R337
R47
R48
TP35
U2
A1
R336
B
2
1
J116
DS17 R292
DS25
3
2
6
A
DS24
C630
C645
C646
C644
C641
C642
A1
R335
U7
R307
A1
C476
A1
TP60
R210
TP53
C468
C519
R1213
Y4
C371
TP74
R211
C153
C156
Y3
R1214
R1212 R1208
R1210 R1207
R1215
R1209
R213 R209
R266
C394
C521
U6
R332
R351
R352
R355
R356
TP70 TP64 R217
TP66
A1
J353
C517
J118
TP73
C484
C554
C471
C530
C528
C526
C625
C518
C599
7
R353
R977
R973
R974
C382
J354
R840
R841
R842
Y20
U4
TP29
CON1
B1
R375
R1211
C463
C422
TP62
TP77 C374
TP26
MH2
U1
J13
C643 C648
R311
R309
C705
C359 R378
DS23
R344
R346
SW5
C113
C129
R54
R55
R69
TP49
C220
TP67
C362
TP56 R70
C360
TP58
C361
TP72
C691
TP11
DS22
R345
J10
R308
C640
C704
J12
J6
R286
C671
C673
C674
R288
TP27
J17
L5
L6
U60
R74R72
J18 R73 R71
C624
R343
SW7
5
TP17 R281
R280
R300
U26
U27
R808
R131
U11
C672
C703
C324
R126
U9
C702
R373
R374
R134
C315
R138
R130
R125
R133
U10
A1
C701 TP28
C700
R294 C699
R289
A1
R141
U12
J23
J16
R143
R137
R139
U49
C606
R396
C325
TP1
R127
CR2
CR1
R136
C323
TP2
C316
5
C164
R298
1
P1
C605
R140
R142
DS26
R160
U62
C292
C330
C331
R111
R112
R78
C283 R81
R76
Y2
C257
C246
J15
R293 R303 R75
R114 C306
C282
R113
J21
R156 R372
C313
R79
R115
R110
R109
R108
R106
R107
C314
U37
C293
R98
R97
R92
R91
R94
R93
R95
R96
R121
R120
C626
C302
R99
J4
U58
J11
J9
J5
J7
C211
C210
C213
C212
C136
C135
C138
C137
C140
C139
C142
C141
C173
C172
C175
C174
C177
C176
C179
C178
C216
C215
C92
C91
C94
C93
C96
C95
J22
C98
TP15
R104
R105
C378
J20
R100
TP71 TP46
C181
C148 R64 C183
R60
TP54
TP33 TP57
TP39
R59
TP50
TP69 R58 C144
C146
R331
TP42
TP44
TP76
R216
C102
C100
R42 TP40
R41
TP38
C103
TP36
TP51 C209
R40
C294
A1
C296
C89
C90
C305
C304
TP75
U8
R218
TP78
J14
C303
TP48
TP31 R63
D15
TP24 R46
L4
J19
R1518
R290
R291
U28
4
R313
C692
J8
J42
R301
J350
TP30
R270
R978
R975
R976
R199
R198
R197
R194
R193
R192
D13
R327
R50
C214
U36
C1575
C1574
C1573
C1572
C1566
R5484 R5483
R334
C1579
D14
R333
D10
R328
R326
TP32
J54
R839
MH1
U162
R179
R178
R177
C623
U16
C351
L3
U17
A1
A40
R116
R117
R118
R119
R101
R102
R103
U19
CR3
Y6
DS28
J30
C926
DS11
DS12
DS13
DS14
DS8
DS9
DS10
CR4
5
C307 C308 C297 C295
1
J33
R191
R190
R189
R188
R184
R183
R182
R181
J352
R1519 R295
C628
K1
K40
R257
R986
R984
R985
R983
C255
DS27
X1
R196
U18
R163 C358 C357
B
LED9
C592
R164
R167
R325
R168
R169
C668
R170
C666
R166
C667
R165
R171
R329
R172
C670
TP23 TP14
R173
R174
R176
R175
B1
C595 R243
J34
A
A1
SW6
B32
Notes:
•
•
•
Jumpers highlighted in red are set by default.
Jumpers highlighted in green are must be set manually.
The location of the jumpers in Figure 19 are searchable.
Revision 5
24
Appendix: Running the Design in Static IP Mode
5
Appendix: Running the Design in Static IP
Mode
The following steps describe how to run the design in Static IP mode:
1.
Right-click the Project Explorer window of SoftConsole project and go to Properties as shown in
Figure 20.
Figure 20 • Project Explorer Window of SoftConsole Project
Revision 5
25
Appendix: Running the Design in Static IP Mode
2.
Remove the symbol NET_USE_DHCP in Tool Settings of the Properties for
Modbus_TCP_top_sb_MSS_CM3_app window. Figure 21 shows the Properties for
Modbus_TCP_top_sb_MSS_CM3_app window.
Figure 21 • Project Explorer Properties Window
Revision 5
26
Appendix: Running the Design in Static IP Mode
3.
If the device is connected in Static IP mode, the board static IP address is 169.254.1.23, then
change the Host TCP/IP settings to reflect the IP address. Refer to Figure 22 and Figure 23 on
page 28.
Figure 22 • Host PC TCP/IP Settings
Revision 5
27
Appendix: Running the Design in Static IP Mode
Figure 23 • Static IP Address Settings
Note: When these settings are made, compile the design, load the design into Flash memory, and run the
design using SoftConsole.
Revision 5
28
Revision History
6
Revision History
The following table shows important changes made in this document for each revision.
Revision
Changes
Revision 5
(March 2016)
Updated the document for Libero v11.7 software release (SAR 76559).
Revision 4
(October 2015)
Updated the document for Libero v11.6 software release (SAR 72924).
Revision 3
(March 2015)
Updated the document for Libero v11.5 software release (SAR 63972).
Revision 2
(May 2014)
Updated the document for Libero v11.3 software release (SAR 56538).
Revision 1
(December 2013)
Updated the document for Libero v11.2 software release (SAR 53221).
Revision 0
(October 2013)
Initial release.
Revision 5
29
Product Support
7
Product Support
Microsemi SoC Products Group backs its products with various support services, including Customer
Service, Customer Technical Support Center, a website, electronic mail, and worldwide sales offices.
This appendix contains information about contacting Microsemi SoC Products Group and using these
support services.
7.1
Customer Service
Contact Customer Service for non-technical product support, such as product pricing, product upgrades,
update information, order status, and authorization.
From North America, call 800.262.1060
From the rest of the world, call 650.318.4460
Fax, from anywhere in the world, 408.643.6913
7.2
Customer Technical Support Center
Microsemi SoC Products Group staffs its Customer Technical Support Center with highly skilled
engineers who can help answer your hardware, software, and design questions about Microsemi SoC
Products. The Customer Technical Support Center spends a great deal of time creating application
notes, answers to common design cycle questions, documentation of known issues, and various FAQs.
So, before you contact us, please visit our online resources. It is very likely we have already answered
your questions.
7.3
Technical Support
For Microsemi SoC Products Support, visit
http://www.microsemi.com/products/fpga-soc/design-support/fpga-soc-support.
7.4
Website
You can browse a variety of technical and non-technical information on the Microsemi SoC Products
Group home page, at http://www.microsemi.com/products/fpga-soc/fpga-and-soc.
7.5
Contacting the Customer Technical Support
Center
Highly skilled engineers staff the Technical Support Center. The Technical Support Center can be
contacted by email or through the Microsemi SoC Products Group website.
7.5.1
Email
You can communicate your technical questions to our email address and receive answers back by email,
fax, or phone. Also, if you have design problems, you can email your design files to receive assistance.
We constantly monitor the email account throughout the day. When sending your request to us, please
be sure to include your full name, company name, and your contact information for efficient processing of
your request.
The technical support email address is [email protected].
7.5.2
My Cases
Microsemi SoC Products Group customers may submit and track technical cases online by going to My
Cases.
Revision 5
30
Product Support
7.5.3
Outside the U.S.
Customers needing assistance outside the US time zones can either contact technical support via email
([email protected]) or contact a local sales office. Visit About Us for sales office listings and
corporate contacts.
7.6
ITAR Technical Support
For technical support on RH and RT FPGAs that are regulated by International Traffic in Arms
Regulations (ITAR), contact us via [email protected]. Alternatively, within My Cases, select Yes
in the ITAR drop-down list. For a complete list of ITAR-regulated Microsemi FPGAs, visit the ITAR web
page.
Revision 5
31
Microsemi Corporation (Nasdaq: MSCC) offers a comprehensive portfolio of semiconductor
and system solutions for communications, defense & security, aerospace and industrial
markets. Products include high-performance and radiation-hardened analog mixed-signal
integrated circuits, FPGAs, SoCs and ASICs; power management products; timing and
synchronization devices and precise time solutions, setting the world's standard for time; voice
processing devices; RF solutions; discrete components; Enterprise Storage and
Communication solutions, security technologies and scalable anti-tamper products; Ethernet
solutions; Power-over-Ethernet ICs and midspans; as well as custom design capabilities and
services. Microsemi is headquartered in Aliso Viejo, Calif, and has approximately 4,800
employees globally. Learn more at www.microsemi.com.
Microsemi Corporate
Headquarters
One Enterprise, Aliso Viejo,
CA 92656 USA
Within the USA: +1 (800) 713-4113
Outside the USA: +1 (949) 380-6100
Sales: +1 (949) 380-6136
Fax: +1 (949) 215-4996
E-mail: [email protected]
© 2016 Microsemi Corporation. All
rights reserved. Microsemi and the
Microsemi logo are trademarks of
Microsemi Corporation. All other
trademarks and service marks are the
property of their respective owners.
Microsemi makes no warranty, representation, or guarantee regarding the information contained herein or
the suitability of its products and services for any particular purpose, nor does Microsemi assume any
liability whatsoever arising out of the application or use of any product or circuit. The products sold
hereunder and any other products sold by Microsemi have been subject to limited testing and should not
be used in conjunction with mission-critical equipment or applications. Any performance specifications are
believed to be reliable but are not verified, and Buyer must conduct and complete all performance and
other testing of the products, alone and together with, or installed in, any end-products. Buyer shall not rely
on any data and performance specifications or parameters provided by Microsemi. It is the Buyer's
responsibility to independently determine suitability of any products and to test and verify the same. The
information provided by Microsemi hereunder is provided “as is, where is” and with all faults, and the entire
risk associated with such information is entirely with the Buyer. Microsemi does not grant, explicitly or
implicitly, to any party any patent rights, licenses, or any other IP rights, whether with regard to such
information itself or anything described by such information. Information provided in this document is
proprietary to Microsemi, and Microsemi reserves the right to make any changes to the information in this
document or to any products and services at any time without notice.
50200440-5/3.16