Está en la página 1de 23
PIC MCU WEB SERVER. 3. Gorasia version 1.1 Contents 1 Introduction 1 Aver 12, Capable 13. About me 14 Arkona 2 Ethernet Baviex 21 TCP AP Model 22 Phyl Mei Overeie 24. Berm Spesigeatns Build he web server 31 Subse S11 PIC Micruoateller(PICI&E 4620) 412 Esheroet Nermirk Comer (ENCISI60) 413. Serial EEPROM (25LC230) SLA Paral LCD (Bites 41760 ie 32 Giron dagen 33 omen tow 4 Getting the web server operational Bis euvrommene enero Dtvain TCP TP Stack Bil a inue “Tes eerie Bull wpa inary Be Upon weg “Tat webpage {5 Webpages and modifying th 51 Bas AIAN. 52 Tram imachm 53 Reco imation SA Alig pce tons stack 6 TCP/IP: tn dept, G1 Frame Sins 62 MAC Atte 63. Stramy Contraco Decmatrtinn 64 Siva timing 83 WN» Strom entvane 86 Auto Negation G7 Auto Comaner 7 Appendix FA” Build of materials n 2 Chapter 1 Introduction 11 Audience “This document i ide deep ste ga eee the WEBE wing 8 it PIC Micon. Preferably Che went ml hove poevinexpetence with PIC MCUs, ving the C18 capital expert that the tender have pane brasil, alte aby toured baie cea anes, A Reema of {TCP IP soe Beene tee 1.2, Capabil Micmhip deatopd a TCP/IP stack fr we with it nage of Esher enable phi, Hk the ENC29900 snd PICISPOTION. "Tis stare stark buble te pbc to bene fawetong we server” Aung he Scie the meb server cau ery ste HTTP, FTP sua DHCP. Thi snake pole to use the pvr or "lesions ke repote ening, bee tation ad oe 1.3 About me 1am Mecha the elation ino sen at Fran W Oli Cull of Engler i Nos. MA. Tis uk ie state fa ineeent sty a sdeepg wa see ng PIC MCUs 1.4 Acknowledgments “Thiseoneavor wo ave lsh edie fu the asc of Prieur Bralley Ml and the revions| trk iy Jorge Ato, Und also lego tha Prof Gil Pratt far povidig ae wih ce spre to Wark, ‘ial she Boats Enger SCOPE vat rth nds eertanens. Chapter 2 Ethernet Basics ‘As Alaska Stator Tl Stevia sid the fter ea seis of es, Ths ub: ery nortan a the er ine bad wo bone a eral nnn fr connie, The Intent a ob systan fierce te erurks that interchange daa by ae secs wing ce standard ater Prose Suite (TCP. 1). Teva Tonework of netmurke” that cot of lla of poate and pb, cade, lie, and rere rk of lc to gba pe that ar ket eppet wit, e-pti cales, wide omnstnye e Veckologies. The Internet saree vrhos information rewire asl serie sich ss leanne caine tha fe ear and le staring onlin gauing, andthe ie il lypetet doce ad ther renee the Weeld Wate Wels (WWW). beret ia aryuemons Carrier See Multiple Aes ith Colson Detect (CSMA/CD) pneu /inerace ws a paglod sizeof 4-100 octes dein er of wig ad sgn snare or te Physea Layer Fhe OST networking mode, mma rns uf tatvurk nots he Media Assen Contd (MAC) Data Link Layer, sd x somaaus dein ort there isda Kink ad pial ayer pool di by she IEEE 802: yi on ean vor; died by mains bth mde of transi ad pal trae, 4 Msn Bit Rate (Mbit/s) 10,100,00 ote 1 Mode of tasmiaon: Broad, Bas + Physic Traian Mei: Cons, Fiber, UTPate ‘The vst of thie eater wil come more dtl abut he TCP IP peed Hi sel a ae about tis before diving i te PIC MICU nna it wll ketal’ emit deta te ert se 2.1 TCP/IP Model 21 Layers To understand bow Ether yuck sft ners tundra the conc of paket ena, and Jao te proto stack Bt ato the cuege Th rate proto io tauy Layers, Eat ler ses for portale bet of fcona. Each Me ayer the tel ute he eligi ‘inet independent bie Th intersting tnt hs that the ney ellie ofthe diet Tages ae pogroned indent ache, ot ist Phang Vite vn AeA DAME me CaS Figure 21: CPAP Stack, Note la she difient layers have many ion Kno vies A pk will sly Isto ae a single service Gs ee aera ead the Mak, A Figure 21 saws, Ue TCP/IP nade is broken up at fe layers, To describe sur foes, wo wil ack the pals packet tate os He stack 1. A web browser would generate « HTTP reguest using an application see eonmand 2. This quest maul bs pe down tothe TCP lye, whic wuld construct TCP che csi of 4 ‘TCP healer and TCH data TCP header euains innate part t te TCP ptr std ket seeing inka, cata ioral he ane al deat pot wer (TTP generally fan ort ser 8) 2. At che IP pro la, sn IP datagram is eunsercte 0 ld oe TCP pce. The IP ae conta ltfortation ot tse of eri, cv nfornaio,prtocd ype (0h for TCP) and he sew ad ‘heaton IP en Th data ld of the IP aagen ct the compete TCP paket tbe ase tue, 4 Ave dt Unk/plgleat lager, the TP datagram i teuspored aero the network ting, te TEBE 802.1 ‘ota A MAC (Mtn Aco Contl frie conse of MAC bre ad MAC pata! (ata). The MAC header cota laferttion sich asthe source MAC adds, the destination MAC ads ud the length ofthe ame. The pao fed eta he vomplete P daagra wo be tans ‘hee ng pa cn igen Figure 22: The evolution f the packet a tavet dna he stack. Notice how the mage stays cml the ‘see atl jst gene nfraton a raved he tac, 2.2 Acronyms ‘There ae many acronyms that enege whos ooking through the stack. They are not very inulin med, and ey dating foe bynes Here x litte een imple thi stack Note at tis ut a Theo all the dent ney the TCP TP nde Punetion ) Mio Tor Big a's a Tver Tanda) one ly tent Layer (IP) Sane aoe Network Laer se se Donat Nae Saree) Merah ag syste Fr eopaters, serves uray sant paripating in the Inter which tales an eal tan Tot their oneal ees ‘DHCP Dyce Contato Prisca [ UaRT I etworked devi (ets) to uta ie | pruners eer for pert a Test is Reaktor Prato - - ‘Priel wen HP aos) | He ie Trad Pstod ‘and afer datos ne per] ‘sche thigh the twee TEETP | pe Tass Paral | Tan fr trig iri SoS innpenet SAP] Sa a Fi Fae — Tae peo el aco Ta To dumpers to nt ee ‘Se MT Ter Przosat | Tiere saa rele fsa wanna ace nero Pro 1) merle [rer rar Ca Praca | TOP pens ab ne dao | ‘see hes fam he prorat om une | "unpter wo anterprogran atoe ee ome wor Tia Danan Praca [UDP TCP wationt mca wa Ta - Lo er env eeking Test) “Tae Canad sage Prasat | Uae i arr dices to eas RI) cst or, ria wo eae er sa ap Pretacat Tia skiplane TP "Tae “Tekconitiation atu | PRATT to avian teas a ote techie Tan ISTRY Har RESO RATS wT Joram, ne ae 8 MAC les 60 a8, L 1 aki TRARP Rives ios Rests Ps 2.2. Physical Medium Overview yn los ope a Ete cb, sn wl 8 fee wires. Th ext 4 sl ps, where ea pa ‘ont of te sel ale wl a gue with Whiston The gro wins ave the trast saa he he range cable are ae ree sa, The ig ad Ina wes are oy aa by Cigar. “Testing ates dcr inte sine the hag ate Ince th win ich detereae he nag oun it te sual) er The tu nce ary dal paste nial erential oe) wich are unnbine byline detaton, The rman ade cae fn thet wis (aot) eae ch thr inthis ition beans th tau ies have nla sat of EMT tht ae 180 ges on of past. This esas 1h these fits subtree rn lo dam elena oat Bu the ele, og ‘we wtetnaion sae eases Th frk oo ROS ok si tater conmunicatiaos uc Be peo pce jack wih negate nage ose ie sgl) ul LEDs [neon forthe upto eee) Ths eet stew are ne tc sore rap Ca the al Jak “Thee an en LEDs) ete ck The ef one babe re al sows he conten syle th rg oe great aol sows the ig activi. HE the Bf LED ia, th vie soi { Ghgaie eooterion,i th oioe sasinga6 HODMD cet we A spat a a pein eg ae aaa I Teas ee RERIIEEEEES] §« Soho nraecrnce ‘Sbagrt Tough Cane ia Cfo TSGBA Figure 2% there cand RIAB pia verview. Takes Gham bp: //owe.artyu.org/eteven.nitel/ 1O-MUps conmetin, If te right LED is Bnking, cere is aciviey othe port. It bon, eat ens Kink bas Tee eal, However of, mo ink hasbeen entablihe 2.3. Ethernet Specifications A Goal detail dre we yt nt the pleat, we neo dacs te costenty of the Sal IP pack hat ‘seat betneenacemoro! vies. Tift af ally lp yo appeiate he design hat men 1. The fein inration i fm ANIL fess Mish” Elberet Theory of Operation a of at 1. Presb - Soe ores of 8, The pene present vo allow the eee tk onto wea). The SED is weties considered ins deb ght ete Stare Frane Dlinter- 10101011 (as wes om the phys ‘orb part of the preseble, This why the preamble it Destination Ades The Gucet MAC an f the destination hardware Sonne Addrss = The Buctt MAC abet of the sour haa 5, Lega Type If le vale i eit 2oeet fi i < 1500 (ei, ths spec dhe ee of ote in he pala fhe ae > 1598, thie rprsents the Eel Type (juslnd ype). The allaving a th ost ‘omni Ether Type vue IPod C800, IPS AUDA, ARP — Gh, RARP 85 ® Pll - The elon dat, suc aan IP dtayrsn te. The sno plod ste 6 ates he ma: nun pavoal sie s1500 ott While pal bel o som thew iit dost et the IEEE S's ean, there fazed supporter eae pylons depeaing the putclar vendor Pal inc the nisin palo son x46 tes aot mise enero es his nu if the Frame Click Squene (FCS) «Theva of the acter FCS field i clea ove te sate airs Ketinaton ad, type, data ad pa fis sig 4 32- Cyeie Retry Check (CRC) 9, Eud-of Sean Delner (ESD) - fs 100 Mb operation, the PHY traits THR stl pls ales te FCS fing te teeta ga) nee ed of th Socal TP_ADL sgl a werk bie cte he df the frame Figu 24: Baie 1 Feo fant Chapter 3 Build the web server In this chapter, se stp nde to build sa wl server ad at We wil be ing a PIC MC with lange arora ie TCP IP proc tak tls wp ln of ata aed progr menu. ke up ee eit Sn sume der toler explain ho hey ate tobe wie 3.1 Subsystems 3.1.1 PIC Microcontroller (PICI8F4620) ‘The PIC Microsntrole cise was PICISEAN2D, I x x ratory sortid PIC MCU wie lange port a datanaehor. 64 ky nd 3968 byes experi. The pin mnbering below fre DIP veri whe T ‘hed. Nie that these vers TBE202 or snr devin) co be med wry} pe wee lr the CDQ in grwn). whit opi, and 8 pis ain se abel! ie) i hi ee, Pin | Funetion| ‘Rema Pn [Function ‘Remar —— 1 [MCE | —iandwane Master Gait [21 | HDD Dior 1 ANG ‘palag tapue 0 a lig pat (ae Sp) -3-]RC SDL far SPrineetne EDO, Satis Thera | RCS $0 fe SPT irre TED aN Tras for dhe USAR TED 2 eos fir te USANT ED tr TO 7 [RT Ti TCD —— ie as) Rb RWI Tie 2] Re Tua Cina ‘ur RDF Unies 3 a[ vob END Ground mp vee W slate i ap No Pas Osilatoe vit | 3 | INT Pr tT Case C5 ENCAINY | Opto apt for ENCHIODINT | Cine ENC CSP ENC CS (Gil SPROST_ C8 | ~BHLCRS6 Sel EEPROSTCS—) ‘Ueah i SCH for SPT [38 [RESET | — Optional ENC2S360 RESET. ir Pec Chick sal for progr Fake Du 1 8.1.2 Ethernet Network Controller (ENC28I60) ‘Ti ENC dh te ft wok of posing the PASCAL how of Enter tortie to the PIC MCU. I comes to de PIC MCU tia SPI this qi Re pas of ee MICU. ste of lig is cet msl. 1 treat ot ad pated th 2 bal fen LIC Eke, This a a he RSJ, ENC2SI6D iy a TIACTIOS\E ci al so dzete oats, The TIACTIOSM i testa Di, ws allows the SPU bas sir eas by ding nee. ‘Tire oa jon tor aly eo pu oper tag eh seb dfn sh age ‘scutpact pang he et. Re ny tot tale tg hs ni, ed ting pee mt revatio ting» be 4.1.8 Serial BEPROM (25LC256) Webpages are wu nc co ig a be ste he open ener ofthe PIC MICU. By fale the WHEY sever wil se exten stil EEPROM to stoethe meget sorta to ke sre that te mage ‘tl cul o Biron the weal EEPROM. Te stack ery the fist yes sae the pats court ration at se tla re "Te ona cathe EEPROM are pete sme, Trad a i, cs the data, aa the € flex 1 de WEBI projet 3.1.4 Parallel LOD (Hitachi 44780 based) LCDs ace x prot wrt cemunicate with ppl, ws ey ae able o display’ a foe, with elas ‘imple corns. Most LCDs core wth a LCD rontoller tac, th st popular ae Ding ae Hitech (790 ehip. This makes hrinerfae to the LCD very snp, eng Uys at most ara pins ae ed We tn st resale een You ean ass eperate i bit mae, wore data pine ure ved, The LCD ‘Seapbofprdcing ny the ACS eharavters using 4 very ee to ACT stax Many Jape chatacters ‘reals pombe To ad xt tare about the tae wel the ing agen eel Er pera toonetp:/mateceatpessas free. fr/Cdelact/Doe-C1/L00/led-nen/USaADReacks ne 3.2. Circuit diagram 3.3 Power on test. To tse if the erat is morn, play an Eiken rable ot the RIS jak ito a neework prt Ky we the LEDs light up. then you have te nic28 board operational. Eni sould be al wa Sou ea pote 10 programming the PIC MCU TE yu te proans geting this morking a incr appr uu be bet. The LEDS othe RAS wll light up if mare wo a werk al nothing else (tl Han fom). Ya sl be able to cetet tthe PIC MCU tng programe Hal ve jus ok thn the crit gra to ae any sta oe TET] SIN @978ZONI est Tad ww Fugue 2.4: NICS oT ae {yaa F . "| ES E £ ¥ - “ MS. IMPORTANT. do wo Chapter 4 Getting the web server operational 4.1 Basic environment considerations Before yn ca beg: doing anything so ned yt mucking enviroment co devs Al the cde preted Ie use the MPLAB IDE (tgs deepen scion) fona Mihi (oesio 810 ate of win) snd the CL ena. This sel halo st deve nC, mie ut enable expen ecard 1o working i wey. “To gee MPLAB, vist ths! sive MPLAB is ditt tno ot ‘To gee the C18 comple, wine thi site Tf sun mat five sett wes, yo Mave to eer wth Mi chips This wil ive yun x 60 day teal fee al mpfr, for wich the ce upizario oedae. The ‘ptutatons ate bor regula fo the me server to iia (te ede tl aang oto the PIC MICU}, ‘Ya lu be al et develop the we sere 4.2 Obtain TCP/IP Stack ‘Te stare fr the tak spe at wes. Batt the ap le and pen up the Microchip MPLAB works, Welt Opes up the fle usig MPLAB. Was cu alo fl ery nile stack abe Sps/ eee A}er-nee/ i607 ENP 13.78.6.2ip. Use the PICIOT projet whi is esetlly the mune asthe WEDS 4.3. Build and import your enviroment setup cores al you ew st bill the fle, The, ang our ogra of ae ( sete PICKET norte ex le iat the ir E620, Figure 4.1: Th ol os 20 bl the poet 4.4 Test connection Som. pg Ethene eal: st Ye RIL jak of bce, a he ther dia all orks. Alerts ‘er ert Fle al lug te rable ot your vps LAN ut sto 9 10 the sad prem, atl use ce ping tty 0 ross Hy dela, the EHCP cule sid, tis the EP aes of the dsc 10 Forde tu te stare (Padres wl operating it le The sel fa te ike 4.5 Build webpage binary file ast ep tbe Ele ian age Ly sig FTP or Fur you mot cea MPFS Wuyi LMPPSEXE wlty ping a angi edi figuration le to ica he opiates conlgnration i ih est of hr tic fen wc F crt the webpages nto any He frat suitable for trig 4.6 Upload webpages upload webpages to the device wean ue au ETP ter. PTD des atch rien FAT aud doce The WEBI ip fil nctdes MPES tnages generated fran the sample HTTP yeas located in she bed {sng in te MPFS ley image wih the staal 16 bit sing fat a BSLCRE or 21,€256/812) wad he ping Lin the bine image with 24 bt DBL C1024), bet fk Tranter coped 4.7 Test webpages “To st whether evrything wrk; open up web ae ad type the IP kites of che deo You sk seth falang, The wetge wl not wrk wl us rms that ve Svar abled a all the dati "sons se sie resents moa oil rae to ctl ees the webpage athe aes Sipe Aerating thet [ipa nee wo su Yrs Mat dows ot ei dsaSript The taper lt bow 2 ul such epg wil dame coment ad wl tothe TCP TP sack i ede to ald ye ome pestis Figuve 4: The bamepage of the WEB meer, Ths shows the dye variables aa allows We ee ter ‘tion wit te pat ttn or the LED Chapter 5 Webpages and modifying the stack 1 ths chapter, I wl over ho terete te webpags spprvpriat for PIC MCUs. Yn wil alt eee a few (CGI Res in rer wo perdu ay Snteravtve tck ts the loess: Use he nl ies at ela 5. Basic AJAX Since wo ar eating dynarie webpages, me wll ed to se AJAX i ode to pate putin of the mye, with mating the whok tng, AJAX sans or AsenchromintsSaaselpt And XML, ceatenation af to Te fst step io a erp to he beer uf let determine the appa NMA Res os ‘Tear Deru ifn teas, ad ig this erp allem inte wel at a fa in mip bowser XAILTepRequsts ze wat i adr pages to pan rts wt refesingthe Figur 5: XMINTTPObj ery to detest the appropriate XMM Res ‘Ten snuther wpe wos ro ye et leans eet the XMLATEp Ress Fall yo have tse her ps tat da stu Figure 52: Sot she be lew be ght ate or AJAX 5.2 Transmit information “The way son tanner frei to te we sever sug tp GET state. This ext a ealbc eo the apace faerie ian). The fant lps thei inte log Teche Hicp segues ae» inden aaenendookag gy — inet anette are ~ oe age ane santa 2 ‘Te faction wil Sst sans evrything fevers tte Sadexcgh toy Nes, wl hiv the suniber for de etal to seeute To singh eosin {heeureu tapemnstin ony lly fr single di esd, oly 10 tnd Thi ie ere ‘twa osc ade be extended. The WEBI sever wl ep an + {anypeged 0-0: whi rgaes LEDE 4 tanypage) 0r1: whl gules LED? Motifsing this Sues i petsy ean en. te me of the ev connie name (wards fr EMD. LEDI}, Joss ald sate smasher with mv ayopaite singh ig ibe The, wo ack 0 he HitpteCnt ftom, lon fr he switch se states that ses ue al ster vena ‘very th pu ad pn at et 5.3. Receive information Te rei frat a fm the wl err, you met tHe specie callback requests. ‘The wu sever ves ll GI He, ling fr predefie omus. Th ores ofl asians AX, wbete NX bse Facial nuns: Bek is Un of te sna hat we special the WEBI sere VARCLEDT 0 WAR TEDE VARCLED? SE stack pate a VAR_IPCNTI_ Tx SIC Tees at ‘WAR_DATE 2 VARCTINE 2 ‘To al moe comma just al anu ase tte eae sie taronunt tht sls th the diferent savible cases I te vie to be retro i jst single digit Wr code sry eanySst mt Ma te Savill at che cesT wil mak wwe te ses). amet, fr loge arabes js et te to Flowing construe: eal ~ vara BYTE) it vain (BVTE}ee] ~~") ‘eturu HTTP_END_OF_VAR: sf saiablel BYTE} He] =~ 0) ‘stars HTTP_END_OF_VAR; recur ‘This eteuc i eile eight aie vara fw ng 5.4 Adding periodic functions ‘There will be a al to pfs period faneion Hike prow an anal sgn, of else Lights, Thee rest shuld nt tke amc ae Orr nut to ert fo the operat othe wes sere An xa {pete Tati spre the Pee fie fh Carey, PronaslO is se to proces ch it tthe alg to digital cguener. You eld a tne proces tthe ProcslO fete ra a Futon snl to Prunes to hai her Chapter 6 TCP/IP: In depth 6.1 Frame Sizes 6.2 MAC Addresses 6.3 Stream Construcion/Deconstruction 6.4 Stream timing 6.5 10 Mb/s Stream contents 6.6 Auto Negotiation 6.7 Auto Crossover Chapter 7 Appendix 7.1 Build of materials Sa Digg Pat None

También podría gustarte