31
October 2015 Running Modbus TCP Reference Design on SmartFusion2 Devices using IwIP and FreeRTOS - Libero SoC v11.6 DG0440 Demo Guide Superseded

DG0440: Running Modbus TCP Reference Design on

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: DG0440: Running Modbus TCP Reference Design on

October 2015

Running Modbus TCP Reference Designon SmartFusion2 Devices using IwIP and

FreeRTOS - Libero SoC v11.6DG0440 Demo Guide

Supers

eded

Page 2: DG0440: Running Modbus TCP Reference Design on

Running Modbus TCP Reference Design on SmartFusion2 Devices using IwIP and FreeRTOS - Libero SoC v11.6

Revision History

Confidentiality StatusThis is a non-confidential document.

Date Revision Change

30 October 2015 4 Fifth release

13 March 2015 3 Fourth release

01 May 2014 2 Third release

09 December 2013 1 Second release

04 October 2013 0 First release

Supers

eded

Page 3: DG0440: Running Modbus TCP Reference Design on

DG0440: Running Modbus TCP Reference Design on SmartFusion2 Devices using IwIP and FreeRTOS - Libero SoCv11.6

Revision 4 3

Table of Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4About this document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Intended Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Modbus Protocol Quick References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Microsemi Publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and FreeRTOS . . . . . . . . . . . . . 5Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Using the Modbus Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Using Modbus Protocol on SmartFusion2 Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Design Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Demo Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Demo Design Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9Demo Design Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Setting uUp the Demo Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Board Setup Snapshot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Running the Demo Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Running Modbus Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Appendix 1: Board Setup for Running the Modbus TCP Reference Design . . . . . . . . . . . . . . . . . . . . . . 22

Appendix 2: Jumper Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Appendix 3: Running the Design in Static IP Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

List of Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Product Support. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Customer Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Customer Technical Support Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Website . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Contacting the Customer Technical Support Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Email . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29My Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Outside the U.S. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

ITAR Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Supers

eded

Page 4: DG0440: Running Modbus TCP Reference Design on

Revision 4 4

Preface

About this documentThis demo is for SmartFusion®2 system-on-chip (SoC) field programmable gate array (FPGA) devices. Itprovides instructions on how to use the corresponding reference design.

Intended AudienceSmartFusion2 devices are used by:

• FPGA designers

• Embedded designers

• System-level designers

ReferencesThe following references are used in this document:

• Modbus Organization: www.modbus.org

– FAQ: www.modbus.org/faq.php

– Technical resources including specifications and links to free and commercial Modbus toolsand 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

• lwIP TCP/IP stack: www.sics.se/~adam/lwip/

• FreeRTOS™ stack: www.freeRTOS.org

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.

Microsemi Publications• 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

Supers

eded

Page 5: DG0440: Running Modbus TCP Reference Design on

Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and FreeRTOS

IntroductionMicrosemi® 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 andimplements the Modbus Protocol. The reference design runs on the SmartFusion2 AdvancedDevelopment 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 TSEMACperipheral. The TSEMAC can be configured between the host processor and the Ethernet network at thefollowing data transfer rates (line speeds):

• 10 Mbps

• 100 Mbps

• 1000 Mbps

Refer to the UG0331: SmartFusion2 Microcontroller Subsystem User Guide for more information on theTSEMAC interface for SmartFusion2 devices.

Using the Modbus ProtocolModbus is an application layer messaging protocol present at the level seven of the open systemsinterconnection (OSI) model. It enables client or server communication between the devices connectedin different types of buses or networks. It is a service protocol that offers many services specified by thefunction 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 networkSup

ersed

ed

Revision 4 5

Page 6: DG0440: Running Modbus TCP Reference Design on

Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and FreeRTOS

Figure 1 describes the Modbus communication stacks for various communication networks.

For more information on Modbus protocol, refer to the "Modbus Protocol Quick References" section onpage 4.

Figure 1 • Modbus Communication Stack

Modbus Application Layer

Modbus on TCP

TCP

IP

Other

Other

Modbus/HDLC

Physical Layer

Master/Slave

EIA/TIA-232 orEIA/TIA-485

Ethernet II/802.3

Ethernet PhysicalLayer

Supers

eded

6 Revision 4

Page 7: DG0440: Running Modbus TCP Reference Design on

DG0440: Running Modbus TCP Reference Design on SmartFusion2 Devices using IwIP and FreeRTOS - Libero SoCv11.6

Using Modbus Protocol on SmartFusion2 DeviceThe Modbus TCP Server runs on the SmartFusion2 Advanced Development Kit and responds to theModbus TCP client running on the host PC. Figure 2 shows the block diagram of Modbus TCP Serverand application on the SmartFusion2 device.

Figure 2 • Block Diagram of Modbus TCP Server and Application on SmartFusion2

Supers

eded

Revision 4 7

Page 8: DG0440: Running Modbus TCP Reference Design on

Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and FreeRTOS

Design RequirementsTable 1 lists the hardware and software design requirements.

Demo Design

IntroductionThe reference design files are available for download from the Microsemi website:http://soc.microsemi.com/download/rsc/?f=m2s_dg0440_liberov11p6_df

The demo design files include:

• Libero SoC project

• Programming files

• HostTool

• Readme.txt file

Table 1 • Reference Design Requirements and Details

Reference Design Requirements and Details Description

Hardware Requirements

SmartFusion2 Advanced Development Kit

• FlashPro5

• USB A to mini-B cable

• 12 V adapter

Rev A 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.6

SoftConsole v3.4 SP1

FlashPro programming software v11.6

USB to UART drivers –

Supers

eded

8 Revision 4

Page 9: DG0440: Running Modbus TCP Reference Design on

DG0440: Running Modbus TCP Reference Design on SmartFusion2 Devices using IwIP and FreeRTOS - Libero SoCv11.6

Figure 3 shows the top-level structure of the design files. For further details, refer to the readme.txtfile.

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 0x04)

– Read holding registers (function code 0x03)

– Write single registers (function code 0x06)

– Write multiple registers (function code 0x10)

– Read or Write multiple registers (function code 0x17)

– Read coils (function code 0x01)

– Write single coil (function code 0x05)

– Write multiple coils (function code 0x0F)

– Read discrete inputs (function code (0x02)

• The reference design supports the following Modbus function codes for all Free Modbus communications stack settings:

– Read input registers (function code 0x04)

– Read discrete inputs (function code (0x02)

– Write multiple coils (function code 0x0F)

– Read holding registers (function code 0x03)

Demo Design DescriptionThe design is implemented using a SGMII PHY interface by configuring the TSEMAC for the ten-bitinterface (TBI) operation. For more information on the TSEMAC TBI interface, refer to theUG0331: SmartFusion2 Microcontroller Subsystem User Guide.

The design comprises:

• Libero SoC Hardware Project

• SoftConsole Firmware Project

Figure 3 • Demo Design Files Top-Level Structure

Supers

eded

Revision 4 9

Page 10: DG0440: Running Modbus TCP Reference Design on

Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and FreeRTOS

Libero SoC Hardware ProjectA Libero SoC v11.6 project uses the SmartFusion2 MSS 1.1.400. Figure 4 shows the hardware designimplementation on which the reference design slave firmware runs.

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

Figure 4 • Libero Top-Level DesignSupers

eded

10 Revision 4

Page 11: DG0440: Running Modbus TCP Reference Design on

DG0440: Running Modbus TCP Reference Design on SmartFusion2 Devices using IwIP and FreeRTOS - Libero SoCv11.6

• 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: IGLOO2 FPGA and SmartFusion2 SoC FPGA High Speed Serial InterfacesUser Guide.

Figure 5 shows the High Speed Serial Interface Configurator window.

Figure 5 • High Speed Serial Interface Configurator WindowSupers

eded

Revision 4 11

Page 12: DG0440: Running Modbus TCP Reference Design on

Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and FreeRTOS

Package Pin AssignmentsPackage pin assignments for LED, DIP switches, push-button switches, and PHY interface signals areshown in Table 2 through Table 5.

SoftConsole Firmware ProjectInvoke 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 (www.sics.se/~adam/lwip/)

• Modbus TCP server version 1.5 (www.freemodbus.org) with enhancements for the completefunction code support as Modbus TCP server

• FreeRTOS (www.freertos.org)

Figure 2 on page 7 shows the block diagram of the Modbus TCP Server and application onSmartFusion2 used in this design.

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 F2Supers

eded

12 Revision 4

Page 13: DG0440: Running Modbus TCP Reference Design on

DG0440: Running Modbus TCP Reference Design on SmartFusion2 Devices using IwIP and FreeRTOS - Libero SoCv11.6

Figure 6 shows SoftConsole software stacks directory structure of the design.

Figure 6 • SoftConsole Project Explorer Window

Supers

eded

Revision 4 13

Page 14: DG0440: Running Modbus TCP Reference Design on

Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and FreeRTOS

Setting Up the Demo DesignThe following steps describe how to setup the demo for SmartFusion2 Advanced Development Kit board:

1. 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.

2. 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.

3. Ensure to have the Location as on USB FP5 Serial Converter C in the Properties window as shown in Figure 7.

4. Make a note of the COM port number for serial port configuration and ensure that the COM portLocation is specified as on USB FP5 Serial Converter C.

5. Install the USB driver if the USB drivers are not detected automatically.

6. 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

Figure 7 • Device Manager WindowSupers

eded

14 Revision 4

Page 15: DG0440: Running Modbus TCP Reference Design on

DG0440: Running Modbus TCP Reference Design on SmartFusion2 Devices using IwIP and FreeRTOS - Libero SoCv11.6

7. Connect the jumpers on the SmartFusion2 Advanced Development Kit board as shown inTable 6. For information on jumper locations, refer to "Appendix 2: Jumper Locations" section onpage 23.

Caution: Switch OFF the power supply switch, SW7, before making the jumper connections.

8. Connect the power supply to the J42 connector in the SmartFusion2 Advanced Development Kit.

9. 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 SnapshotSnapshots of the SmartFusion2 Advanced Development Kit board with all the setup connections aregiven in the following appendix: "Appendix 1: Board Setup for Running the Modbus TCP ReferenceDesign" section on page 22

Running the Demo DesignThe following steps describe how to run the demo design:

1. Download the design file from:http://soc.microsemi.com/download/rsc/?f=m2s_dg0440_liberov11p6_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 theConfiguring Serial Terminal Emulation Programs Tutorial.

4. Launch the FlashPro software.

5. Click New Project.

Table 6 • SmartFusion2 Advanced Development Kit Jumper Settings

Jumper Pin (from) Pin (to) Comments

J116, J353, J354,J54 1 2 These are the default jumper settings of the AdvancedDevelopment Kit board. Ensure that jumpers are setaccordingly.J123 2 3

J124, J121, J32 1 2 JTAG programming via FTDI

J118, J119 1 2 Programming SPI Flash

Supers

eded

Revision 4 15

Page 16: DG0440: Running Modbus TCP Reference Design on

Running Modbus TCP Reference Design on SmartFusion2 Using IwIP and FreeRTOS

6. In the New Project window, enter the Project Name.

7. Click Browse and navigate to the location where you want to save the project.

8. Select Single device as the Programming mode.

9. Click OK to save the project.

10. Click Configure Device.

11. 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.

Figure 8 • FlashPro New Project

Supers

eded

16 Revision 4

Page 17: DG0440: Running Modbus TCP Reference Design on

DG0440: Running Modbus TCP Reference Design on SmartFusion2 Devices using IwIP and FreeRTOS - Libero SoCv11.6

Figure 9 • FlashPro Project Configured

Supers

eded

Revision 4 17

Page 18: DG0440: Running Modbus TCP Reference Design on

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 indicatingthat the program passed. This demo requires the SmartFusion2 device to be preprogrammedwith the application code to activate the Modbus application. The SmartFusion2 device ispreprogrammed with the Modbus_TCP_top.stp using FlashPro software.

Note: To run the design in Static IP mode, follow the steps mentioned in "Appendix 3: Running theDesign in Static IP Mode" section on page 24.

13. Power cycle the SmartFusion2 Advanced Development board.

Figure 10 • FlashPro Program Passed

Supers

eded

18 Revision 4

Page 19: DG0440: Running Modbus TCP Reference Design on

DG0440: Running Modbus TCP Reference Design on SmartFusion2 Devices using IwIP and FreeRTOS - Libero SoCv11.6

A welcome message with the IP address is displayed in the HyperTerminal window as shown in Figure 11.

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 11 • HyperTerminal with IP Address

Figure 12 • Invoking the Modbus Client

Supers

eded

Revision 4 19

Page 20: DG0440: Running Modbus TCP Reference Design on

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)

Refer to the "Running Modbus Functions" section on page 21 for more information on the Modbus functions that are demonstrated in the reference design.

15. After running the demo, close HyperTerminal.

Figure 13 • Modbus Functional Codes DemonstrationSup

ersed

ed

20 Revision 4

Page 21: DG0440: Running Modbus TCP Reference Design on

DG0440: Running Modbus TCP Reference Design on SmartFusion2 Devices using IwIP and FreeRTOS - Libero SoCv11.6

Running Modbus FunctionsThis section describes the Modbus functions that are demonstrated in the reference design.

Read Discrete Inputs (function code 02)GPIOs are connected to 4 DIP switches and 4 push-button switches. Switch ON and switch OFF the DIPswitches and push-button switches on the SmartFusion2 Advanced Development Kit. Read discreteinputs functional code displays the statuses of switches as shown in Figure 14.

Read Holding Registers (function code 03)Figure 15 shows the global buffer data defined in the firmware.

Read Input Registers (function code 04)Figure 16 shows the number of seconds that the real-time counter (RTC) has counted.

Write Multiple Coils (function code 0x0F)Figure 17 shows the Write Multiple Coils register data for toggling the LEDs connected to GPIOs.

Figure 14 • Read Discrete Inputs

Figure 15 • Read Holding Registers

Figure 16 • Read Input Registers

Figure 17 • Write Multiple Coils

Supers

eded

Revision 4 21

Page 22: DG0440: Running Modbus TCP Reference Design on

Appendix 1: Board Setup for Running the Modbus TCP Reference Design

Appendix 1: 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 Setup

RJ45-Cable

USB Mini-BConnector

SW6 to resetPower supplyswitch SW7

DC Jackto connect12 V Adapter

Push buttonswitches

LEDs

DIPswitchesPush button

switch

Supers

eded

22 Revision 4

Page 23: DG0440: Running Modbus TCP Reference Design on

DG0440: Running Modbus TCP Reference Design on SmartFusion2 Devices using IwIP and FreeRTOS - Libero SoCv11.6

Appendix 2: Jumper Locations

Figure 19 shows the jumper locations on the SmartFusion2 Advanced Development Kit board.

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.

Figure 19 • SmartFusion2 Advanced Development Kit Silkscreen Top View

DS3

R318

R362

R369

SW5

R277

TP35

C638

SW4

DS2

DS1

Y11

C692

R1216

C698

R280

C697 C696

R278

R279

J29

J28

C332

J125

C610DS0

R364

R338

R336

R337

R335

R346

R344

R345

R343

R1217

TP17

U59

R276

R283

R255

U25

J121

DS20

DS21

DS19

DS18

DS25

DS23

DS24

DS22

R281

R300

J123

R282

TP3

C600

C604

J124

R151

R152

DS17

U58

R155

U34

R330R162

J32

R161

R147

H1

R148

R292

TP11

U26

TP7

C596

J36

C691

R313

R301

TP20

SW1

J116

DS29

U23

R260

J38

J37

C593

SW7

R354

TP4

R253

U24

U27

D9

J42

TP12

R267 DS16

J351

TP16

J60

P1

J33

MH2

C323

R136CR1

R298 C164

CR2

DS26

MH1

SW6

R142

R140

J23

C605

J21

J19

L3

CR3

CR4

DS27

R138

U12

R396

C606

U36

C351

U16

U19

C595

X1

R243 LED9

C316 U9

R126R127

U10

R141

C325 R1

37R1

43

TP2

R325

R326R328

R164

D13

R167

R168

R169

C358

R163

C357

U18

C315

TP27

U11

R131

R125R133

R130

C324R1

39

TP1

R112

R111

R113

R114

C313

R97

C303

R100

C668

C666

C667

R327

R165

R170

R171

U17

R199

R194

R197

R198

R373

R374

R288

C699

R294

R289

J16

C306

C307

C308C314

C295

C297

R98

C293

C302R99

TP14

TP23

R329

L4

C670

R176

R172

R173

R174

R175

R182

R184

R181

R189R190R191R1

92R193

J34

C704

C705

U60

C700

C702

C701

J15

C282

R106R107

R108R109R110R115R120R121

R93R95R96

R104R105

R91R92

R94

C623 J20

J22TP15

TP24

R46

U28

D14

R177R178

R985

TP26

C703

L6

TP28

C674

C292

C283

Y2

C255 R116

R79

DS11

DS12

J14

R50 C2

14

R5484

C156

6

U162

R983

R257

R984

R842

R840

R841

J354

C672

R156

C673

U37

R372C331

R78

R81R76

C330

U8

R101

R117

R118

R119

DS13

DS14

DS8

R331

U62

R333C1579

D10

R5483

C157

4C1

575

C157

3

Y6

R1519

J352R839

R355R356

R351R352

R332

J353

L5

R293

C626

C624

R303 C246

C257 J17

R75

R102

R103 TP36

DS10

DS9

TP76

D15

R291

R290

C1572

R334

R270

R160

R295

TP29

R286

C671

C625

R73R74

J18

C382

R218TP75

C305C304

C296C294

R40

C378

R216

C98

TP33 TP57TP69

TP31

R975

R976R978

R973

R974

R977

C926

CON1

R71R72

TP78

TP51

R41TP38

R58

TP42

R63

TP48

C521

C394

C528

C526

C530

C471

C554

C484

C90C89

C209C103

C100

TP73

C144

TP54

C181

TP71

R808

TP77 C374

C210

C211

R42C102

R59C146TP44

R60C148

TP46

U6

TP70

C136

C135

C212

C213

TP40

TP39

R64

TP66

R217TP64

C142

C140

C139

C138

C137

TP50

C183

TP53

U1

C173

C172

C141

U2

R210TP60

C174

C175

C176

C177

J30

C179

C178

C216

C215

U3

C94

C93

C91

C92

R266

R121

2R1

210R1

208

R120

7

R375

C359Y3

C360

C361

Y4

C362C220

C95

C96

U5

R120

9R1

215 Y20

R121

4

R1211

R378

TP74

C371

TP56

R69

J4

J7

U4

C599

C463C422

R211

C153

C156

TP72

R70 C109

C150

TP58

TP49TP67

TP10

C467

TP41TP62

C468

R213R1

213

C518

C562

C233

C161

C119

C236

C235

C199

J6

J5

DS28

C647TP22

C460

C455

C519

R209

TP68

C328

C197

C163

C118

C465

C159

C116

R353

R310

U32

C646

C645

C644

J118

R363

R361

U13

R150

C476

C517

R54R55

J54

TP30

C628

C643

C648

R309

R311

C642

C641

J119

J13

C129

C113

J12

TP32

R308

R307

D7D8

TP21

TP9

R366

R149

U35

R220

R272C608

C630

DS7

R314

R316

R158

R159

C640

R305R3

06C636

R222

R224

DS6

DS5

Y12

R47R48

U7

J10

J8

J9

J11

J350

U31

R304

C637

SW3

SW2

DS4

1

1

2

1

2

B

A

6

5

4

19

20

19

20

9

10

3

21

32

C1

C40

H1

H40

13

25

47

68

1

2

B

A

B

A

B

A

A1 A1 A1

A1

A1

K1

A1

A40

K40

B32

A1

B1

R986

A1

R151

8

R166

R183

R188

R196

A1

R179

5

1

5

1

B1

A1

U49

B

A

R134

C592

Supers

eded

Revision 4 23

Page 24: DG0440: Running Modbus TCP Reference Design on

Appendix 3: Running the Design in Static IP Mode

Appendix 3: 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

Supers

eded

24 Revision 4

Page 25: DG0440: Running Modbus TCP Reference Design on

DG0440: Running Modbus TCP Reference Design on SmartFusion2 Devices using IwIP and FreeRTOS - Libero SoCv11.6

2. Remove the symbol NET_USE_DHCP in Tool Settings of the Properties for Modbus_TCP_MSS_CM3_app window. Figure 21 shows the Properties for Modbus_TCP_MSS_CM3_app window.

Figure 21 • Project Explorer Properties Window

Supers

eded

Revision 4 25

Page 26: DG0440: Running Modbus TCP Reference Design on

Appendix 3: 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, thenchange the Host TCP/IP settings to reflect the IP address. Refer to Figure 22 and Figure 23 onpage 27.

Figure 22 • Host PC TCP/IP Settings

Supers

eded

26 Revision 4

Page 27: DG0440: Running Modbus TCP Reference Design on

DG0440: Running Modbus TCP Reference Design on SmartFusion2 Devices using IwIP and FreeRTOS - Libero SoCv11.6

When these settings are made, compile the design, load the design into Flash memory, and run thedesign using SoftConsole.

Note: To run the application in debug mode, FlashPro4 JTAG programmer is required.

Figure 23 • Static IP Address Settings

Supers

eded

Revision 4 27

Page 28: DG0440: Running Modbus TCP Reference Design on

Revision 4 28

List of Changes

The following table shows important changes made in this document for each revision.

Date Changes Page

Revision 4(October 2015)

Updated the document for Libero v11.6 software release (SAR 72924). NA

Revision 3(March 2015)

Updated the document for Libero v11.5 software release (SAR 63972). NA

Revision 2(May 2014)

Updated the document for Libero v11.3 software release (SAR 56538). NA

Revision 1(December 2013)

Updated the document for Libero v11.2 software release (SAR 53221). NA

Revision 0(October 2013)

Initial release. NA

Supers

eded

Page 29: DG0440: Running Modbus TCP Reference Design on

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.

Customer ServiceContact 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.1060From the rest of the world, call 650.318.4460Fax, from anywhere in the world, 408.643.6913

Customer Technical Support CenterMicrosemi SoC Products Group staffs its Customer Technical Support Center with highly skilledengineers who can help answer your hardware, software, and design questions about Microsemi SoCProducts. The Customer Technical Support Center spends a great deal of time creating applicationnotes, 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 answeredyour questions.

Technical SupportFor Microsemi SoC Products Support, visit http://www.microsemi.com/products/fpga-soc/design-support/fpga-soc-support

WebsiteYou can browse a variety of technical and non-technical information on the SoC home page, at http://www.microsemi.com/products/fpga-soc/fpga-and-soc.

Contacting the Customer Technical Support CenterHighly skilled engineers staff the Technical Support Center. The Technical Support Center can becontacted by email or through the Microsemi SoC Products Group website.

EmailYou 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, pleasebe sure to include your full name, company name, and your contact information for efficient processing ofyour request.

The technical support email address is [email protected].

Supers

eded

Revis ion 4 29

Page 30: DG0440: Running Modbus TCP Reference Design on

Product Support

My CasesMicrosemi SoC Products Group customers may submit and track technical cases online by going to My Cases.

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.

ITAR Technical SupportFor 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.

Supers

eded

30 Revis ion 4

Page 31: DG0440: Running Modbus TCP Reference Design on

50200440-4/10.15

Microsemi Corporate HeadquartersOne Enterprise, Aliso Viejo,CA 92656 USA

Within the USA: +1 (800) 713-4113 Outside the USA: +1 (949) 380-6100Sales: +1 (949) 380-6136Fax: +1 (949) 215-4996

E-mail: [email protected]

Microsemi Corporation (Nasdaq: MSCC) offers a comprehensive portfolio of semiconductorand system solutions for communications, defense & security, aerospace and industrialmarkets. Products include high-performance and radiation-hardened analog mixed-signalintegrated circuits, FPGAs, SoCs and ASICs; power management products; timing andsynchronization devices and precise time solutions, setting the world’s standard for time; voiceprocessing devices; RF solutions; discrete components; security technologies and scalableanti-tamper products; Ethernet solutions; Power-over-Ethernet ICs and midspans; as well ascustom design capabilities and services. Microsemi is headquartered in Aliso Viejo, Calif., andhas approximately 3,600 employees globally. Learn more at www.microsemi.com.

© 2015 Microsemi Corporation. Allrights reserved. Microsemi and theMicrosemi logo are trademarks ofMicrosemi Corporation. All othertrademarks and service marks are theproperty of their respective owners.

Microsemi makes no warranty, representation, or guarantee regarding the information contained herein orthe suitability of its products and services for any particular purpose, nor does Microsemi assume anyliability whatsoever arising out of the application or use of any product or circuit. The products soldhereunder and any other products sold by Microsemi have been subject to limited testing and should notbe used in conjunction with mission-critical equipment or applications. Any performance specifications arebelieved to be reliable but are not verified, and Buyer must conduct and complete all performance andother testing of the products, alone and together with, or installed in, any end-products. Buyer shall not relyon any data and performance specifications or parameters provided by Microsemi. It is the Buyer'sresponsibility to independently determine suitability of any products and to test and verify the same. Theinformation provided by Microsemi hereunder is provided "as is, where is" and with all faults, and the entirerisk associated with such information is entirely with the Buyer. Microsemi does not grant, explicitly orimplicitly, to any party any patent rights, licenses, or any other IP rights, whether with regard to suchinformation itself or anything described by such information. Information provided in this document isproprietary to Microsemi, and Microsemi reserves the right to make any changes to the information in thisdocument or to any products and services at any time without notice.

Supers

eded