Home

AN10845 Porting uIP1.0 to LPC1700

image

Contents

1. ICIP Fackets received 28 r Packets sent 28 Packets dropped 0 Type errors 0 TCP Packets received 86 Packets sent T3 Fackets dropped 0 Checksum errors Data packets without ACKs Resets Retransmissions No connection avaliable Connection attempts to closed ports Fig 11 Network statistics of ulP web server Click the hyper link Network connections the current connections will be displayed Welcome to the ulP web server Microsoft Internet Explorer File Edit View Favorites Tools Help Q ee 9 x a A pi Search P Favorites 4 R si te af rel Address http 192 168 0 100 tep shtml Front page File statistics Network statistics Network connections Current connections Local Remote State Retransmissions Timer Flags 80 192 168 0 99 2711 ESTABLISHED 0 a 80 192 168 0 99 2712 TIME VWAIT 0 1 Fig 12 Network connections of ulP web sever NXP B V 2009 All rights reserved Application note Rev 01 30 June 2009 10 of 13 NXP Semiconductors AN1 0845 Porting ulP1 0 to LPC1700 3 Conclusion With the success of the Internet the TCP IP protocol suite has become a global standard for communication For embedded systems being able to run native TCP IP makes it possible to connect the system directly to an intranet or even the global Internet Embedded devices with full TCP IP support will be first class network citizens thus being able to fully communicate with other hosts i
2. 1 0845 Porting ulP1 0 to LPC1700 BOOL 34 EMAC SendPacket void pPacket UNS 34 3126 UMS 32 Index UMS 32 IndexNext EMAC gt TxProducetIndex 1 if size Q returni TRUE iffIndexNext gt EMAC gt TxDescriptorNumber IndexNext O iffIindexNext EMAC gt TxConsume Index return FALSE Index EM amp C gt TxProducelInde x if size gt ETH FRAG SIZE size ETH FRAG SIZE memcpy unsiqned int TX BUF Index pPacket size TX DESC CTRL Index Ox7Titr TX DESC CTRL Index size 1 amp OxvTttT ENAC gt TxProducelIndex IndexNext returni TRUE Fig 5 Implementation of function EMAC_SendPacket 2 2 4 3 Porting tapdev_read AN10845_1 Function tapdev_read will eventually call Ethernet driver EMAC_ReadPacket see loc17xx_emac c Fig 6 shows the receive process in the view of software Start Rx array is empty Parse the descriptor Retrieve a frame data Update RxConsumelndex et Fig 6 Flow chart of receive process NXP B V 2009 All rights reserved Application note Rev 01 30 June 2009 7 of 13 NXP Semiconductors AN1 0845 Porting ulP1 0 to LPC1700 Note If the receive datapath is enabled the Ethernet block will continue to receive frames until the receive descriptor array is full Fig 7 shows the implementation of function EMAC_ReadPacket UNS 32 EMAC
3. AN10845 Porting ulP1 0 to LPC1700 Rev 01 30 June 2009 Application note Document information Info Content Keywords ulP TCP IP Stack LPC 1700 Abstract This application note describes the steps and details of porting ulP a light weight TCP IP Stack to LPC1700 A simple web server is implemented as a demo founded by Philips NXP Semiconductors AN1 0845 Porting ulP1 0 to LPC1700 Revision history Rev Date Description 01 20090630 Initial version Contact information For additional information please visit http Awww nxp com For sales office addresses please send an email to salesaddresses nxp com AN10845_1 NXP B V 2009 All rights reserved Application note Rev 01 30 June 2009 2 of 13 NXP Semiconductors AN1 0845 Porting ulP1 0 to LPC1700 1 Introduction 2 Porting ulP AN10845_1 The Ethernet block of LPC1700 contains a full featured 10 100 Mbps Ethernet MAC designed to provide optimized performance through the use of DMA hardware acceleration Features include a generous suite of control registers half or full duplex operation flow control control frames hardware acceleration for transmit retry receive packet filtering and wake up on LAN activity Automatic frame transmission and reception with Scatter Gather DMA off loads many operations from the CPU The ulP TCP IP stack is an extremely small implementation of the TCP IP protocol suite intended for embedded sys
4. OT OW TEPENE EE AE S E E 3 2 2 Porting description cccseeeecceeeeeeeeeeeeneeeeeseees 3 2 2 1 PLOPAratiOn ccccsececcsseeecceseeeceeseeeseueeeceeneesssees 3 2 2 2 Modify porting directory and files 00 4 2 2 3 Porting Timer Crivelr ccccccccccseseeeceeeeeeeeeeeeaees 4 2 2 4 Porting Ethernet driver ccceccceeeeseeeeeeeeeeees 5 2 2 4 1 Porting tapdev_init ceeeccceessseeeeeeeeeeeeeeeees 5 2 2 4 2 Porting tapdev_Send cceeeeeeeeeeeeeeeeeeeeeees 6 2 2 4 3 Porting tapdev_read ceeeeeeeeeeeeeeeeeeeeeeeees T 2 2 5 Main loop CONTIOL ccccseeeeeeseeeeeeeeeeeeeeeeeeeaees 8 2 3 Demo description cccceeeeeeeceeeeeeeeeeaeeeeeeeeaeees 8 3 CONGCIUSION ecesas 11 4 Legal information ccccccssseeeseeneeseenseeeeeneeenes 12 4 1 Definitions cccceeeeecceeeeeceeeeeeceeeeesseseesseneeeens 12 4 2 BUSE e e E 12 4 3 Trademarks rntesicccacentccnaennedennsascensacenacdtestecsandees 12 5 CONTENT Scrin A 13 founded by Porting ulP1 0 to LPC1700 Please be aware that important notices concerning this document and the product s described herein have been included in the section Legal information NXP B V 2009 All rights reserved For more information please visit http www nxp com For sales office addresses email to salesaddresses nxp com Date of release 30 June 2009 Document identifier AN10845_1
5. ReadPacket void pPacket i UNS 32 Index EMAC gt RxConsumelIndex UNS 34 3126 if Index EMAC gt RxProduceInde x returni0Ol size RE STAT INFO Index amp Ox fj 4 1 if size gt ETH FRAG SIZE size ETH FRAG SIZE memcpy pPacket unsigned int RA BUF Index 5126 if i Index gt EMAC gt RxDescriptorNumber Index OU EMN amp C gt RxeConsumetIndex Index Feturn slzel gt Fig 7 Implementation of function EMAC_ReadPacket 2 2 5 Main loop control The main loop control is in the source file main c Before entering the main loop all system functions and devices must be initialized including LPC1700 vector interrupt controller serial port for debug timer Ethernet and HTTP server etc MAC and IP address should be also set here The ulP stack can be run either as a task in a multitasking system or as the main program in a singletasking system In both cases the main control loop does two things repeatedly e Check if a packet has arrived from the network e Check if a periodic timeout has occurred 2 3 Demo description As ademo we create a new uVision3 project and implement a web server based on ulP1 0 Note Function snprintf is used in source file httpd cgi c but not implemented in old version of Keil RealView MDK In this case MicroLIB can not be used in the project See Fig 8 AN10845_1 NXP B V 2009 All rights reserved Application note Rev 01 30 Ju
6. n the network Compared with other TCP IP stack implementation ulP consumes a lot less memory while still providing basic TCP IP stack capabilities making it suitable for small memory footprint embedded devices like those in the LPC1 700 series AN10845_1 NXP B V 2009 All rights reserved Application note Rev 01 30 June 2009 11 of 13 NXP Semiconductors AN10845 4 Legal information 4 1 Definitions Draft The document is a draft version only The content is still under internal review and subject to formal approval which may result in modifications or additions NXP Semiconductors does not give any representations or warranties as to the accuracy or completeness of information included herein and shall have no liability for the consequences of use of such information 4 2 Disclaimers General Information in this document is believed to be accurate and reliable However NXP Semiconductors does not give any representations or warranties expressed or implied as to the accuracy or completeness of such information and shall have no liability for the consequences of use of such information Right to make changes NXP Semiconductors reserves the right to make changes to information published in this document including without limitation specifications and product descriptions at any time and without notice This document supersedes and replaces all information supplied prior to the publication hereof S
7. ne 2009 8 of 13 NXP Semiconductors AN10845 Porting ulP1 0 to LPC1700 Options for Target MCB1 7 00 IRAM Device Target Output Listing User C C Asm Linker Debug Utilities NXP founded by Philips LPC1768 Xtal MHz fiz r Code Generation Operating system None M Use Cross Module Optimization F Use MicroLlB F Big Endian Read Only Memory Areas default off chip Start Size TA ff Romz CE Romh on chip IROM1 x1 0000000 ox8000 IROM2 gt Startup r Read Write Memory Areas F Use Link Time Code Generation default off chip Start Size i E l i r IRAM1 IRAM2 0x2007C000 0 6000 Nolnit Fig 8 Project options without use of MicroLIB Modify the IP configuration of your laptop to be in the same LAN with evaluation board Internet Protocol TCP IP Properties General You can get IP settings assigned automatically if your network supports this capability Otherwise you need to ask your network administrator for the appropriate IP settings Obtain an IP address automatically IP address Subnet mask Default gateway Obtain DNS se Preferred DNS server Alternate DNS server etver at ddress Use the following DNS server addresses automatically 192 168 0 99 255 255 255 0 192 168 0 254 SS Fig 9 IP Configuration in lapto
8. ors AN10845 AN10845_1 Porting ulP1 0 to LPC1700 It is also useful to be familiar with the LPC Ethernet and Timer blocks by reading the appropriate sections of the LPC1700 user manual The latest user manual can be downloaded from the NXP website http www standardics nxp com support documents microcontrollers 2 2 2 Modify porting directory and files 1 Modify the directory name of unix to main 2 Create a sub directory pc1700 and add LPC1700 related source file here uip_webserver_src_ Olpct 700 apps Lc clock arch c gt Lst ih clock arch h Ei e main c Ipe1700 IE tapdev c L obj Lh tapdev h iC uip h uip conf h C 3 uip_webserver_sre_ LE core_cmi3 c O apps h core_cm3 h E Lst Ln LPCL xx h O main E Ipc17xx_emac c W f ipc1700 h Ipc17xx_emac h n Obj r Ipc17xx_systick c C uip n lpcl xx_systick h C uip_webserver_src_ n Ipc_types n vip webserver src C Retarget c G 7_Software tools Ei startup_LPC17xx s O 8 Images le system LPC1FXX C C Utility h system LPC1 s0 h sre h target h Fig 2 Files in main directory up and lIpc1700 directory down 2 2 3 Porting Timer driver The timer library provides functions for setting resetting and restarting timers and for checking if a timer has expired Two timer functions must be implemented prototypes are defined in header file clock h in ulp direc
9. p Link and start debug in internal RAM then type 192 168 0 100 in the address bar of the web browser The main page of the ulP web server should now be visible AN10845_1 NXP B V 2009 All rights reserved 9 of 13 Application note Rev 01 30 June 2009 NXP Semiconductors AN1 0845 Porting ulP1 0 to LPC1700 4 Welcome to the ulP web server Microsoft Internet Explorer File Edit View Favorites Tools Help Q Bac x a A pO Search 5 Favorites E B amp 7 h rel Address http 192 168 0 100 Front page File statistics Network statistics Network connections These web pages are served by a small web server running on top of the uIP embedded TCPAP stack Click on the links above for web server statistics Fig 10 Main page of ulP web sever Click the hyper link Network statistics the current network statistics will be displayed 4 Welcome to the ulP web server Microsoft Internet Explorer File Edit View Favorites Tools Help Q sek X x a A Search 5 Favorites amp B z K rel Address Sy http 192 168 0 100 stats shtml Frontpage File statistics Network statistics Network connections ee Le Network statistics IP Packets received 119 Packets sent 86 Packets dropped 28 IP errors IP version header length 0 IP length high brte 0 IF length low byte 0 IP fragments 0 Header checksum 0 Wrong protocol 0
10. tapdev_init Function tapdev_init will eventually call Ethernet driver EMAC_Init see lpc17xx_emac c After reset the Ethernet software driver needs to initialize the Ethernet block During initialization the software needs to 1 Remove the soft reset condition from the MAC Configure the PHY via the MIIM interface of the MAC Select RMII or MII mode Configure the transmit and receive DMA engines including the descriptor arrays Configure the host registers MAC1 MAC2 etc in the MAC Enable the receive and transmit datapaths Oo oO A W N Depending on the PHY the software needs to initialize registers in the PHY via the MII Management interface The software can read and write PHY registers by programming the MCFG MCMD MADR registers of the MAC The MIIM clock divider ranges from 4 to 28 which will result in a MIIM clock ranging from 0 6 MHz to 4 5 MHz if PCLK is set to 18 MHz Although IEEE802 3u defines the clock to be no faster than 2 5 MHz some PHYs may support the clock up to 12 5 MHz for example DP83848 For the physical address of DP83848 PHY on KEIL MCB1700 board since the PHYAD 0 pin has weak internal pull up resistor and PHYAD 4 1 pins have weak internal pull down resistors the default setting for the PHY address is 00001 0x1 After initializing the receive descriptor and status arrays to receive frames from the Ethernet connection both the receive DMA controller and receive datapath of the MAC need
11. tems running low end 8 or 16 bit microcontrollers The code size and RAM requirements of ulP is an order of magnitude smaller than other generic TCP IP stacks today It can only handle a single network interface and contains the IP ICMP UDP and TCP protocols This application note describes the steps and details of porting the ulP TCP IP stack latest version is 1 0 to LPC1700 As a demo a simple web server is implemented and tested on KEIL MCB1 700 board Based on this document users can easily port ulP to other NXP MCU with Ethernet block 2 1 Overview 2 2 2 2 1 There is no need to make any changes to the actual ulP TCP IP code but a device driver for the target s network device Ethernet controller serial port whatever has to be written The actual system integration part i e the main control loop which should call the ulP functions when data arrives and when the periodical timer expires also has to be done Porting description Preparation The ulP can be downloaded from its official website http Awww nxp com redirect sics se uip Read the reference manual to understand the file structure work flow and especially the main control loop 50 I apps I dhepe O hello world O resolv smtp telnetd O webclient webserver doc c lib uip Tn unix Fig 1 File structure of ulP NXP B V 2009 All rights reserved Application note Rev 01 30 June 2009 3 of 13 NXP Semiconduct
12. to be enabled To prevent overflow in the receive DMA engine the receive DMA engine should be enabled by setting the RxEnable bit in the Command register before enabling the receive datapath in the MAC by setting the RECEIVE ENABLE bit in the MAC1 register See Fig 3 AN10845_1 NXP B V 2009 All rights reserved Application note Rev 01 30 June 2009 5 of 13 NXP Semiconductors AN1 0845 Porting ulP1 0 to LPC1700 rx descr init tx descr initi Enable receive and transmit mode of MAC Ethernet core MAC COMMAND CR RE EN CR TX EN Hac Maci Maci REC EW return TRUE Fig 3 Enable receive DMA controller and receive datapath of MAC 2 2 4 2 Porting tapdev_send Function tapdev_send will eventually call Ethernet driver EMAC_SendPacket see loc17xx_emac c Fig 4 shows the transmit process in the view of software only om N Set up the descriptor Packet and Control field Update TxProducelndex En Fig 4 Flow chart of transmit process Note If the transmit datapath is enabled the Ethernet block will start transmitting the frame as soon as it detects the TxProducelndex is not equal to TxConsumelndex both were zero after reset Fig 5 shows the implementation of function EMAC_SendPacket AN10845_1 NXP B V 2009 All rights reserved Application note Rev 01 30 June 2009 6 of 13 NXP Semiconductors AN
13. tory 1 clock_time_t clock_time void 2 void clock_init void Function clock_time returns the current system clock time which is measured in system ticks Function clock_init initializes the clock library and should be called from the main function of the system The timer driver is implemented in file clock arch h and clock arch c will eventually call timer functions in lpc17xx_systick c The files containing arch mean that are architecture specific implementations In this demo LPC1700 SysTick Timer is used and fired every 10 milliseconds NXP B V 2009 All rights reserved Application note Rev 01 30 June 2009 4 of 13 NXP Semiconductors AN1 0845 Porting ulP1 0 to LPC1700 2 2 4 Porting Ethernet driver The Ethernet library provides functions for initializing Ethernet block transmitting and receiving Ethernet frame in LPC1 700 Three Ethernet functions must be implemented which are defined in file tapdev h with some minor modifications compared with the original file 1 void tapdev_init void 2 unsigned int tapdev_read void pPacket 3 void tapdev_send void pPacket unsigned int size Function tapdev_init initializes the LPC1700 Ethernet block including MAC and DMA controller and PHY chip Function tapdev_read receives an Ethernet frame from MAC DMA controller Function tapdev_send transmits an Ethernet frame to MAC DMA controller 2 2 4 1 Porting
14. uitability for use NXP Semiconductors products are not designed authorized or warranted to be suitable for use in medical military aircraft space or life support equipment nor in applications where failure or malfunction of a NXP Semiconductors product can reasonably be expected AN10845_1 Porting ulP1 0 to LPC1700 to result in personal injury death or severe property or environmental damage NXP Semiconductors accepts no liability for inclusion and or use of NXP Semiconductors products in such equipment or applications and therefore such inclusion and or use is for the customer s own risk Applications Applications that are described herein for any of these products are for illustrative purposes only NXP Semiconductors makes no representation or warranty that such applications will be suitable for the specified use without further testing or modification Export control This document as well as the item s described herein may be subject to export control regulations Export might require a prior authorization from national authorities 4 3 Trademarks Notice All referenced brands product names service names and trademarks are property of their respective owners NXP B V 2009 All rights reserved Application note Rev 01 30 June 2009 12 of 13 NXP Semiconductors AN10845 5 Contents 1 HEF OCUGUION soas 3 2 Poning UIP sesscceceseivessncceetedecccatenectaxsetessaxcessataceones 3 2 1 D

Download Pdf Manuals

image

Related Search

Related Contents

HAWK-I Template Reference Guide  estudio de frecuencia de casos de infección por citomegalovirus  1 - Panasonic Canada    Duratech User Manual  MONITOR MA 512 HUMANO V1.9B  Manifestation Jeunesse - Mairie d`Aix-en  YA-F10/YA-F20 Guía del usuario * - Support  取扱説明書 (施主様向)  DISTRIBUIDOR INTERNO ÓPTICO DIO BT VERSIÓN CORTA  

Copyright © All rights reserved.
Failed to retrieve file