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

 

  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

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.