• Menu
  • Product
  • Email
  • PDF
  • Order now
  • Serial to Ethernet Converter for TM4C129x Microcontrollers Using RTOS

    • SPMA072 March   2015 TM4C1294KCPDT , TM4C1294KCPDT , TM4C1294NCPDT , TM4C1294NCPDT , TM4C1294NCZAD , TM4C1294NCZAD , TM4C1299KCZAD , TM4C1299KCZAD , TM4C1299NCZAD , TM4C1299NCZAD , TM4C129EKCPDT , TM4C129EKCPDT , TM4C129ENCPDT , TM4C129ENCPDT , TM4C129ENCZAD , TM4C129ENCZAD , TM4C129XKCZAD , TM4C129XKCZAD , TM4C129XNCZAD , TM4C129XNCZAD

       

  • CONTENTS
  • SEARCH
  • Serial to Ethernet Converter for TM4C129x Microcontrollers Using RTOS
  1.   Serial to Ethernet Converter for TM4C129x Microcontrollers Using RTOS
    1.     Trademarks
    2. 1 Introduction
    3. 2 Software Description
    4. 3 Set Up and Program enet_s2e Application
      1. 3.1 Set Up enet_s2e Application
      2. 3.2 Software Modification for DK-TM4C129X
      3. 3.3 Program the enet_s2e Application
    5. 4 Demonstration
      1. 4.1 Set Up EK-TM4C1294XL Board and PC
      2. 4.2 Demonstration
    6. 5 Configuration Webserver
      1. 5.1 Access the Configuration Webserver
        1. 5.1.1 Using the Debug Port
        2. 5.1.2 Using the Finder Utility
      2. 5.2 Different Pages Hosted on the Configuration Webserver
        1. 5.2.1 S2E Status Page
        2. 5.2.2 S2E Port 0 and Port 1 Settings Page
        3. 5.2.3 S2E Miscellaneous Settings Page
    7. 6 Flow Control
    8. 7 Additional Hardware
      1. 7.1 Schematic of RS-232 Level Shifter
      2. 7.2 Connections
      3. 7.3 Bill of Materials (BOM)
    9. 8 References
  2. IMPORTANT NOTICE
search No matches found.
  • Full reading width
    • Full reading width
    • Comfortable reading width
    • Expanded reading width
  • Card for each section
  • Card with all content

 

APPLICATION NOTE

Serial to Ethernet Converter for TM4C129x Microcontrollers Using RTOS

Serial to Ethernet Converter for TM4C129x Microcontrollers Using RTOS

Some legacy products may only contain a serial port and accessing such products is increasingly becoming a challenge due to the inability to add multiple such products to a shared network and the inability to access the legacy product from long distances. A serial-to-Ethernet converter provides a simple solution to solve the above challenges. The software described in this application report allows an Ethernet-based TM4C129x microcontroller to be used as a serial-to-Ethernet converter. TM4C129x microcontroller is ideally suited for this application due to the integration of MAC and PHY on the microcontroller along with on-chip voltage regulator. This allows quicker time-to-market and cost savings. The software uses FreeRTOS to schedule the various tasks and runs out of the box on an EK-TM4C1294XL board.

Project collateral and source code discussed in this application report can be downloaded from the following URL: http://www.ti.com/lit/zip/spma072.

Trademarks

Code Composer Studio, Tiva are trademarks of Texas Instruments.

Keil is a registered trademark of ARM Limited.

IAR is a trademark of IAR Systems AB.

All other trademarks are the property of their respective owners.

1 Introduction

When a legacy product only contains a serial port for configuration or control, continuing to access the legacy product through the serial interface can become challenging over time. The following are the challenges of using a serial port:

  • The inability to add multiple such products to a shared network
  • The inability to access the legacy product from long distances
  • Modern PCs generally do not have RS-232 ports

Using Ethernet in place of the serial port provides the following benefits:

  • The legacy product can be more easily shared (instead of changing a cable connection, a new connection over the existing network is made)
  • Ability to access from longer distances. Cable length is no longer an issue
  • Ethernet is a more common interface available on today’s computing equipment

The software described in this application report (enet_s2e) allows an Ethernet-enabled TM4C129x microcontroller to be used as a serial-to-Ethernet converter. By connecting a serial-to-Ethernet converter to the serial port of a legacy product, it can be given the ability to operate on the Ethernet without requiring any changes to the existing hardware or software. This is especially useful when the legacy product cannot be modified (such as in the case of third-party products).

The software works out of the box on an EK-TM4C1294XL board. With minor modifications, the software can run on the DK-TM4C129X board. For details, see Section 3.2.

FreeRTOS has been used for scheduling the various tasks. Although an RTOS is not a requirement for this application, it has been used to make the application easily scalable.

2 Software Description

The main function of the enet_s2e application is to transfer information between serial peripherals and the Ethernet. To transfer information over the Ethernet, Telnet protocol is used. A number of features are provided in the application to make this process easy to use and robust. The following are some of these features.

  • Two Serial-to-Telnet port pairs: Port0 and Port1
  • Dynamic configuration of Serial and Telnet port settings
  • Dynamic IP address configuration
  • HTTP server to manage dynamic configuration parameters
  • Locator service to find the IP address of the board (to access HTTP server)
  • EEPROM access to store configuration data

The application runs a webserver to manage the dynamic/run-time configuration of many parameters. For more details of the configuration webserver and the different settings, see Section 5.2.

This application uses two serial peripherals and two Telnet ports. The serial peripheral and Telnet port are configured such that each serial peripheral can transmit and receive data to and from only one Telnet port. There are two such serial-Telnet pairs, represented by Port0 and Port1. By default, the serial interface of Port0 and Port1 are assigned to UART4 and UART3 peripherals, respectively. This default peripheral assignment can be modified in config.h file. If the default peripheral assignment is modified, then the assignment of the interrupt handlers SerialPort0IntHandler and SerialPort1IntHandler in the vector table should also be modified. The vector table is located in the start-up file.

The Telnet ports can be configured in both server and client modes along with the necessary parameters like port number and IP address. By default, both the Telnet ports are configured as server. The Telnet ports used by Port0 and Port1 are 23 and 26, respectively.

Port0 and Port1 settings can be modified dynamically. You also have an option to make these modifications permanent. For more details about these settings, see Section 5.2.2. The default values of these settings are stored in the global array g_sParametersFactory (present in the config.c file).

The enet_s2e application uses FreeRTOS to run multiple tasks in a concurrent fashion, a TCP/IP stack, called lwIP, to handle the TCP/IP packets and TivaWare for C Series that includes peripheral driver library and other utilities that simplify application development. Figure 1 shows the interaction between different software layers of this application.

Figure01_SPMA072.gifFigure 1. Software Layers of enet_s2e Application

The enet_s2e.c file contains the main function and performs the initialization before handing over control to the FreeRTOS scheduler. The tasks and their responsibilities are as follows:

  • A TCP/IP task to run the lwIP stack and manage all the TCP/IP packets
  • An Ethernet task to manage the Ethernet interface and its interrupt
  • A serial task to manage the serial peripherals and their interrupts
  • An idle task (automatically created by FreeRTOS) to manage changes to IP address

The TCP/IP task and Ethernet task are created and managed by the lwIP library.

The data transfer between the serial peripherals and telnet sockets is handled by the TelnetHandler() function (present in telnet.c file), which is called by lwIPHostTimerHandler() function (present in lwip_task.c file). The lwIPHostTimerHandler() function runs in the TCP/IP task context.

3 Set Up and Program enet_s2e Application

3.1 Set Up enet_s2e Application

  1. Download and install TivaWare for C Series v2.1.0.12573 or later from the URL: http://www.ti.com/tool/SW-TM4C.
  2. Download the enet_s2e application source code from the URL: http://www.ti.com/lit/zip/spma072. The zip file has two folders that need to be extracted: enet_s2e and utils.
  3. Copy the enet_s2e folder to the EK-TM4C1294XL board’s folder in TivaWare for C Series. The default installation path of TivaWare for C Series is C:/ti and the EK-TM4C1294XL board’s folder is located at ../TivaWare_C_Series-2.1.0.12573/examples/boards/ek-tm4c1294xl/.
  4. The utils folder has two files: eeprom_pb.c and eeprom_pb.h. Copy them into the utils folder in TivaWare for C Series located in ../TivaWare_C_Series-2.1.0.12573/utils.
  5. Open the project in one of the toolchains and build the project to create a binary file. The supported toolchains are Code Composer Studio™, Keil® MDK, IAR™ Embedded Workbench and GNU.

3.2 Software Modification for DK-TM4C129X

Use the following steps to run the enet_s2e application on the DK-TM4C129X board:

  1. Download and extract the zip file as described in Section 3.1. Then, copy the enet_s2e folder into the DK-TM4C129X board’s folder located at ../TivaWare_C_Series-2.1.0.12573/examples/boards/dk-tm4c129x/.
  2. Open the project in one of the supported toolchains and modify the project settings as follows:
    1. Replace the labels PART_TM4C1294NCPDT and TARGET_IS_TM4C129_RA1 with PART_TM4C129XNCZAD and TARGET_IS_TM4C129_RA0 in the project settings.
    2. Uncomment the line that defines the label DK_TM4C129X in the enet_s2e.c file.
  3. Rebuild the project.

3.3 Program the enet_s2e Application

  1. Power up the microcontroller by connecting the micro (smaller) end of the USB cable to the USB connector on the EK-TM4C1294XL board. Then, connect the other end of the USB cable to a free USB port on the PC.
  2. As soon as the EK-TM4C1294XL board is powered up, the ICDI and Stellaris Virtual Serial Port drivers are installed.
  3. Program the binary to the microcontroller. Then, reset the board to run the enet_s2e application. Now, the EK-TM4C1294XL board starts behaving as an S2E module.

NOTE

To verify whether the ICDI drivers are installed correctly (or if there is trouble programming the binary), see the Stellaris® In-Circuit Debug Interface (ICDI) and Virtual COM Port Driver Installation Instructions (SPMU287).

4 Demonstration

A simple set up, like the one shown in Figure 2, demonstrates the serial-to-Ethernet functionality of TM4C129x. Section 4.1 and Section 4.2 provide instructions on how to use two Terminal windows on a PC to loop data back and forth between a serial peripheral and Ethernet peripheral of the PC using the S2E module. Although either of the Serial-to-Telnet port pairs could be used for this demonstration, Port 0 is used in this documentation.

Figure02_SPMA072.gifFigure 2. S2E Demonstration Representation

4.1 Set Up EK-TM4C1294XL Board and PC

  1. Connect one end of the Ethernet cable to the Ethernet jack on EK-TM4C1294XL board and the other end to LAN with DHCP server present (like router).
  2. For the schematic and connections for a simple circuit to level shift the CMOS/TTL signal of the universal asynchronous receiver/transmitter (UART) on EK-TM4C1294XL board to RS-232 levels, see Section 7.1 and Section 7.2.
  3. Connect one end of a DB9 cable as described in Section 7.1 and Section 7.2 and the other end to the PC. If the PC does not have a DB9 port, then use a DB9 to USB converter cable.
  4. Connect the micro (smaller) end of the USB cable to the USB connector on the EK-TM4C1294XL board. Then, connect the other end of the USB cable to a free USB port on the PC. This will power-up the board.

4.2 Demonstration

  1. Open the first terminal window (like Hyperterminal or TeraTerm) and connect to the Stellaris Virtual Serial Port COM port. This port is used as a debug terminal to display the IP address and status messages. From now on, this terminal is referred to as debug terminal.
  2. Select the Baud rate as 115200, Data Bits as 8, Parity as none, Stop bits as 1 and Flow Control as none.
  3. Open a second terminal window and connect to the COM port associated with the port that the DB9 cable is connected to on the PC. This terminal will be referred to as Serial Terminal.
  4. Select the Baud rate as 115200, Data Bits as 8, Parity as none, Stop bits as 1 and Flow Control as none.
  5. Program and run the enet_s2e application. For detailed instructions to program the enet_s2e application, see Section 3.
  6. A banner and status messages are printed on the debug terminal. Proceed only after the IP address is acquired and displayed on the debug terminal.
  7. Open a third terminal window to connect to the TCP/IP port 23 (or Telnet). This terminal will be referred to as Telnet terminal.
  8. Select TCP/IP. If a particular protocol is required, choose Telnet. Set the Port number to 23. Set the Host IP address to the IP address shown on the debug terminal.
  9. Information typed on either Serial or Telnet terminals will be displayed on the other terminal and vice versa. The text might not be displayed in the transmitting window based on the terminal windows setting.

This demonstrates that the S2E module routes back the serial data from PC as Telnet data (over Ethernet) and vice versa. In other words, the S2E module transmits Telnet data when it receives serial data and transmits serial data when it receives Telnet data.

The configuration webserver can be accessed by entering the IP address, displayed on the debug terminal, into a web browser. For more details on this webserver, see Section 5.

5 Configuration Webserver

The enet_s2e application hosts an embedded webserver that provides a convenient configuration interface.

5.1 Access the Configuration Webserver

The configuration webserver of the S2E module can be accessed by:

  • Using the Debug port
  • Using the Finder utility

 

Texas Instruments

© Copyright 1995-2025 Texas Instruments Incorporated. All rights reserved.
Submit documentation feedback | IMPORTANT NOTICE | Trademarks | Privacy policy | Cookie policy | Terms of use | Terms of sale