AN2836 Freescale Semiconductor / Motorola, AN2836 Datasheet

no-image

AN2836

Manufacturer Part Number
AN2836
Description
Web Server Development with MC9S12NE64 and OpenTCP
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Freescale Semiconductor
Application Note
Web Server Development with
MC9S12NE64 and OpenTCP
By: Steven Torres
Introduction
Ethernet connectivity of embedded devices is a growing trend in industrial and consumer applications.
Ethernet is a medium of choice because of its competitive performance, relatively low price of
implementation, established infrastructure, and inter-operability. Ethernet is also easy to use, widely
available, and scalable. Ethernet is described by IEEE Standard 802.3
With Ethernet and TCP/IP data transmission, embedded devices can be connected to the Internet, which
allows access to the embedded device from across the world.
an embedded device that is connected to a remote host via the Internet.
embedded device and remote host can operate on different networks, but the connection between the
devices is transparent.
This product incorporates SuperFlash technology licensed from SST.
© Freescale Semiconductor, Inc., 2004. All rights reserved.
8/16 Bit System Engineering
Austin, Texas
MOTOR
EMBEDDED DEVICE
CONTROL
Figure 1. Embedded Device on Internet
BOARD
INTERNET
Figure 1
shows a simplified illustration of
.
Figure 1
REMOTE HOST
shows that the
Rev. 0, 9/2004
AN2836

Related parts for AN2836

AN2836 Summary of contents

Page 1

... EMBEDDED DEVICE CONTROL MOTOR This product incorporates SuperFlash technology licensed from SST. © Freescale Semiconductor, Inc., 2004. All rights reserved. INTERNET BOARD Figure 1. Embedded Device on Internet Rev. 0, 9/2004 ™ . Figure 1 shows a simplified illustration of Figure 1 shows that the REMOTE HOST AN2836 ...

Page 2

Acronyms and Terms Acronyms and Terms Acronym/ Description Term ARP Address resolution protocol AN Auto-negotiate BIOS Basic input/output system BOOTP Bootstrap protocol DHCP Dynamic host configuration protocol DNS Domain name server FTP File transfer protocol HTML Hyper text mark-up language ...

Page 3

Scope of This Application Note This application note details the creation of a web server for an embedded device. The discussion will provide an overview of development with the MC9S12NE64 and the OpenTCP TCP/IP stack. This application note specifically addresses ...

Page 4

Scope of This Application Note Connectivity Example Applications Connectivity systems that use the TCP/IP stack model (see example in Figure 1, can be implemented for a wide range of applications, including: • Database data logging or queries • Web servers ...

Page 5

MC9S12NE64 MCU with Integrated Ethernet Controller This section introduces the MC9S12NE64 MCU and provides a brief overview of the MC9S12NE64 Ethernet controller. MC9S12NE64 The MC9S12NE64 is a 16-bit MCU based on Freescale Semiconductor’s HCS12 CPU platform. It includes 8K of ...

Page 6

Axiom Ethernet Development Board for the MC9S12NE64, EVB9S12NE64 HCS12 CPU WITH DEBUG MODULE 2 X SCI SPI IIC V REG 3 2.5 V CONVERTER 18 KEY WAKEUP IRQ PORTS EPHY EMAC Figure 4. Block Diagram of the MC9S12NE64 ...

Page 7

See the Axiom Manufacturing website, http://www.axman.com, for more information. Because the MC9S12NE64 connects directly to an Ethernet connector and high-speed LAN magnetic isolation module, the MC9S12NE64 is a true single-chip Ethernet system solution. Figure 5. EVB9S12NE64 Evaluation Board from Axiom ...

Page 8

Axiom Ethernet Development Board for the MC9S12NE64, EVB9S12NE64 Figure 6. EVB9S12NE64 Top Layer and Silkscreen EVB9S12NE64 OSC_SEL, select Y1 crystal oscillator circuit CONFIG switch 1–4 CONFIG switch 5 CONFIG switch 6 COMM_SW 1–8 PWR_SW USER_EN switch, RVI_EN MODA, MODB, MOBC, ...

Page 9

OpenTCP TCP/IP Stack Overview This section includes: • OpenTCP introduction • Freescale Semiconductor low-level Ethernet drivers • OpenTCP installation and project organization • OpenTCP CodeWarrior project • OpenTCP TCP/IP stack API OpenTCP Introduction OpenTCP is a robust and portable implementation ...

Page 10

OpenTCP TCP/IP Stack Overview Figure 7. OpenTCP Project Directory Structure Table description of several sub-directory that are shown in Table 3. OpenTCP Project Sub-Directory Descriptions Sub-Directory {Project Directory}\Docs {Project Directory}\NE64_OpenTCP {Project Directory}\OpenTCP {Project Directory}\NE64_OpenTCP\bin {Project Directory}\NE64_OpenTCP\prm {Project ...

Page 11

More information on ne64_OpenTCP.mcp is provided in the following sections. ne64_OpenTCP.mcp opened in the CodeWarrior IDE (integrated development environment). Figure 8. CodeWarrior IDE with OpenTCP Projects Open Web Server Development with MC9S12NE64 and OpenTCP, Rev. 0 Freescale Semiconductor OpenTCP TCP/IP ...

Page 12

OpenTCP TCP/IP Stack Overview OpenTCP CodeWarrior Projects This section details the files in ne64_OpenTCP.mcp . The specific files that are discussed are the files that will likely require modification in order to develop the simple web server described by this ...

Page 13

OpenTCP TCP/IP Stack API Table 5 provides a more detailed look at OpenTCP by reviewing some basic API OpenTCP functions including a brief description for each function. For complete documentation of the OpenTCP API, please reference the OpenTCP user guide. ...

Page 14

... Configuring TCP/IP protocol in Microsoft Windows operating system Development Environment and Tools The OpenTCP TCP/IP stack software can be modified and compiled with the CodeWarrior environment. Below are specific details about the development environment and tools used to develop the web server described in this application note. • ...

Page 15

PC Figure 9. Connecting the Evaluation Board This step provides an easier interface for debugging the application than connecting directly to a real network (because the development target is isolated). To make the application compatible with a ...

Page 16

Preparing for OpenTCP TCP/IP Stack Development Configuring the IP Addresses IP addresses are assigned by a network administrator or a dynamic host configuration protocol (DHCP) server. These addresses are used by the IP layer of the OpenTCP TCP/IP stack. If ...

Page 17

Configuring TCP/IP Protocol in Windows To set up the IP address for the development host in Windows, the IP address network settings of the development host must be accessed in its operating system. For recent Windows releases, these settings are ...

Page 18

Preparing for OpenTCP TCP/IP Stack Development 2. Manually enter a subnet mask and specific IP address. Recall that the IP address used for the development host in this example is 192.168.1.1. Figure 11. Opening Internet Protocol (TCP/IP) Properties Dialog Box ...

Page 19

Debugging Networks Issues Issues with network connectivity are typically due to an error in the network setup and configuration of either the network or the remote devices. Three main network connectivity issues and their possible solutions are described in this ...

Page 20

... This issue may require assistance from a system administrator to resolve. Network Protocol Analyzer Tools A network protocol analyzer is a powerful and useful tool for network debugging. The network protocol analyzer enables more visibility of packet traffic on the network connection. A network protocol analyzer is used to monitor the connectivity of the Internet or a local area network (LAN) ...

Page 21

Overview of a Web Server Developed Using OpenTCP TCP/IP Stack This section provides an overview of the web server and source code developed with OpenTCP. A graphical overview of the web server is shown in This web server is developed ...

Page 22

Overview of a Web Server Developed Using OpenTCP TCP/IP Stack The remainder of this section will overview some of the files and source code that were modified during development of the OpenTCP web server demo. Acronyms and terms used in ...

Page 23

Before coding the web server application code recommended that the basic MC9S12NE64 hardware and software options are configured. These configuration options include: • MAC hardware address • IP address • Auto-negotiation • EMAC options • EPHY options ...

Page 24

Overview of a Web Server Developed Using OpenTCP TCP/IP Stack ne64config.h An excerpt of the source code for ne64config.h is provided below. ne64config.h allows the user to configure initialization options for the MC9S12NE64 EMAC and EPHY. The code excerpt below ...

Page 25

Configuration //============================================================ #define BUFMAP //============================================================ //EMAC FILTERING CONTROL //============================================================ //Address Filtering; RXMODE setting: PAUSE frame supported, Accept Unique, Brodcast, MultiCast #define BRODC_REJ #define CON_MULTIC #define PROM_MODE //Ethertype Control #define ETYPE_PET 0 #define ETYPE_EMW 0 ...

Page 26

Overview of a Web Server Developed Using OpenTCP TCP/IP Stack Individual Buffer Size BUFMAP Setting for BUFMAP less than 4 are provided to: • Maximize user RAM • Provide a filtering mechanism base on Ethernet ...

Page 27

... The HTML source code for demo.htm is provided in this section. HTML web page development can be assisted with web tools, such as FrontPage by Microsoft, but it is not required. A simple text editor could be used, for example. Web pages can contain standard and advanced HTML components including, but not limited to: • ...

Page 28

... Page</a><img border="0" src="space.gif" width="125" height="13"><a href="features.htm">NE64 Features</a><img border="0" src="space.gif" width="125" height="13"><a href="devtools.htm">Development Tools</a><img border="0" src="space.gif" width="125" height="13"><a href="demo.htm">Demo</a></font><font size="1" face="sans-serif" ...

Page 29

In order to run this ActiveX component, the Visual Basic run-time files are required.&nbsp;&nbsp; Please download the Visual Basic 6 run-time files if the ActiveX ...

Page 30

... AN2863SW.zip from freescale.com) to provide the hash calculation, hashcalculator.exe . This hash calculator is provided without any guarantees. Table 8 provides a brief description of each file referenced by the web server. Table 8. Files Referenced by the Web Server Filename index.htm devetools.htm features.htm demo.htm freescale.jpg space.jpg NE64DemoNDPIC.cab Web Server Development with MC9S12NE64 and OpenTCP, Rev. 0 ...

Page 31

... Version : 1.0 * Date : Mar/05/2004 * * ******************************************************************************/ #include "FileSys.h" /********* Include Web server files here *************/ #include "index.h" #include "NE64DemoNOPIC.h" #include "demo.h" #include "devtools.h" #include "features.h" #include "freescale.h" #include "space.h" /*****************************************************/ const TFileEntry FAT [] = { { 115, index_file, { 247, NE64DemoNOPIC_file, ...

Page 32

Overview of a Web Server Developed Using OpenTCP TCP/IP Stack #include "datatypes.h" #include "timers.h" #include "system.h" #include "ethernet.h" #include "arp.h" #include "ip.h" #include "tcp_ip.h" #include "http_server.h" #include "smtp_client.h" #include "ne64driver.h" #include "ne64api.h" #include "mBuf.h" #include "ne64config.h" #include "udp_demo.h" #include "address.h" ...

Page 33

ATDCTL2 = ATDCTL2_ADPU_MASK | ATDCTL2_AFFC_MASK; ATDCTL3_S1C = seq. ATDCTL3_FIFO = FIFO ATDCTL3_FRZ = 3; // Freeze immediately in BDM ATDCTL4 = ATDCTL4_PRS2_MASK |ATDCTL4_PRS1_MASK | ATDCTL4_PRS0_MASK; ATDCTL4 = ATDCTL4 & ~ATDCTL4_SRES8_MASK; //10 bit ...

Page 34

Overview of a Web Server Developed Using OpenTCP TCP/IP Stack INTCR_IRQEN = 0; after CPU reset by default initialize processor-dependant stuff (I/O ports, timers...). * Most important things this function as far as the TCP/IP ...

Page 35

DEBUGOUT(">>>>>>>>>Entering to MAIN LOOP>>>>>>>>>\n\r"); for (;;) { #if USE_SWLED UseSWLedRun(); #endif if (gotlink take care of watchdog stuff */ /* Try to receive Ethernet Frame*/ if( NETWORK_CHECK_IF_RECEIVED() == TRUE ) { switch( received_frame.protocol) { ...

Page 36

OpenTCP Project Configuration to Optimize the Stack Solution OpenTCP Project Configuration to Optimize the Stack Solution When developing a web server, there are several strategies to ensure that the code size of the solution does not exceed the available resources: ...

Page 37

Figure 14. Example of UDP Application Replacing the Web Server • Off-load web page data to an external memory device interfaced to the MC9S12NE64 via the expanded memory or using one of the MC9S12NE64 serial interfaces. Softec (www.softecmicro.com) provides a ...

Page 38

OpenTCP Project Configuration to Optimize the Stack Solution Use Only Required Network Protocols For resource-constrained TCP/IP stack implementations, such as implementing a TCP/IP stack on an 8-/16-bit embedded system not always best to implement the complete set of ...

Page 39

... Although specific methods and tools are used to develop and debug this demo, Freescale Semiconductor does not recommend or endorse any particular methodology, tool, or vendor. These methods and tools are provided only to describe the generic principles and features that may be required for development of a networked device ...

Page 40

... Learn More: For more information about Freescale Semiconductor products, please visit http://www.freescale.com AN2836 Rev. 0, 9/2004 Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document ...

Related keywords