Tim Hieu Mplab Ide v8.56

Click here to load reader

  • date post

    26-Jun-2015
  • Category

    Documents

  • view

    1.851
  • download

    2

Embed Size (px)

Transcript of Tim Hieu Mplab Ide v8.56

Tm hiu MPLAB IDE v8.56 Chng I : M U 1) Gii thiu v MPLAB IDE:

GVHD: M Duy Khanh

Ngn ng assembly (cn gi l hp ng) l mt ngn ng bc thp c dng trong vic vit cc chng trnh my tnh. Ngn ng assembly s dng cc t c tnh gi nh, cc t vit tt gip ta d ghi nh cc ch th phc tp v lm cho vic lp trnh bng assembly d dng hn. Mc ch ca vic dng cc t gi nh l nhm thay th vic lp trnh trc tip bng ngn ng my c s dng trong cc my tnh u tin thng gp nhiu li v tn thi gian. Mt chng trnh vit bng ngn ng assembly c dch thnh m my bng mt chng trnh tin ch c gi l assembler (Mt chng trnh assembler khc vi mt trnh bin dch ch n chuyn i mi lnh ca chng trnh assembly thnh mt lnh ca my). Cc chng trnh vit bng ngn ng assembly lin quan rt cht ch n kin trc ca my tnh. iu ny khc vi ngn ng lp trnh bc cao, t ph thuc vo phn cng. Trc y ngn ng assembly c s dng kh nhiu nhng ngy nay phm vi s dng kh hp, ch yu trong vic thao tc trc tip vi phn cng hoc hoc lm cc cng vic khng thng xuyn. Ngn ng ny thng c dng cho trnh iu khin (driver), h nhng bc thp (low-level embedded systems) v cc h thi gian thc. Nhng ng dng ny c u im l tc x l cc lnh assembly nhanh. MPLAB IDE l mt phn mn lm mi trng lp trnh cho chp PIC. y cng l mt cng c kh mnh cho lp trnh iu khin, v n chy trn PC pht trin cc ng dng cho h thng qun l vi mch ca Microchip . N c gi l mt mi trng pht trin tch hp, hay IDE, bi v n cung cp mt tch hp "mi trng" pht trin m cho nhng h qun l vi mch.

Tm hiu MPLAB IDE v8.56

GVHD: M Duy Khanh

Hin ti cng c nhiu phn mn h tr lp trnh bin dch cho Pic nhng MPLAB IDE vn l phn mn m nhiu ngi s dng nht do Microchip sn xut dng ring cho cc h vi x l dng Pic. Nu ch mi phn mn ny khng th ngi lp trnh ch lp trnh ngn ng ASM trn n. Nhng lp trnh C ch hn th ngi dng phi ci thm mt s cng c cho n nh l C18, C30...th n s h tr c trnh C. Chu trnh thit k ca MPLAB(chu trnh khp kn ) c tm gn nh hnh bn di.

Chu trnh thit k Bin dch / assemble / Link Code Ti v m Debugger phn tch / Sa li m Sa / To / Thit k m ngun

y l chu trnh khp kn t lc bin dch cho n lc xut ra m *.hex, trong bao gm cc qu trnh sa cha Debugger.

Tm hiu MPLAB IDE v8.56 2) Chc nng ca MPLAB IDE:

GVHD: M Duy Khanh

MPLAB IDE l mt chng trnh phin dch t ngn ng Assembly sang ngn ng PIC (m *.hex). H tr mt s mch np PICkit2,PICkit3,N cn h tr cc tnh nng kim tra li Debugger dung MPLAP SIM, Debug onchip dng Mplab ICD2., cho ta bit gi tr ca cc thanh ghi cng nh b nh ca chip, gi tr ca cc thanh ghi SFR.

Tm hiu MPLAB IDE v8.56

GVHD: M Duy Khanh

Chng II : HNG DN S DNG

Trc tin c MPLAP bn phi ti n v my tnh ca bn, bn c th vo a ch sau: http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406 &dDocName=en019469&part=SW007002. (8.56) Sau khi download v my ta m Folder cha chng trnh v Double Click vo biu tng setup.exe v lm theo cc bc di y. 1) Ci t: Sau khi Double Click vo biu tng setup.exe mn hnh s hin ln nh bn di.

Tm hiu MPLAB IDE v8.56

GVHD: M Duy Khanh

Click Next

Chn I accept Click Next

Tm hiu MPLAB IDE v8.56

GVHD: M Duy Khanh

Click Next

Click Next

Tm hiu MPLAB IDE v8.56

GVHD: M Duy Khanh

Click Next

Click Next

Tm hiu MPLAB IDE v8.56

GVHD: M Duy Khanh

Click Next

Ngi chn khi tin trnh ci t hon tt.

Tm hiu MPLAB IDE v8.56

GVHD: M Duy Khanh

Click Next

Chn I accept Next

Tm hiu MPLAB IDE v8.56

GVHD: M Duy Khanh

V cui cng l Finish Thc hin y cc bc trn th chc chn l bn c mt chng trnh phc v cho vic hc lp trnh bng ngn ng cp thp (Assembly). y ta khng c cc bc b kha v chng trnh ny do microchip cung cp hon ton min ph.

Tm hiu MPLAB IDE v8.56 2) S dng chng trnh:

GVHD: M Duy Khanh

Double Click vo biu tng MPLAB IDE v8.56 trn Desktop hoc lm theo cch sau: Click vo Start v8.56 All Programs Microchip MPLAP IDE

MPLAP IDE ta s c mt ca s giao tip vi chng trnh nh bn di.

Trc khi thc hin cc thao tc lm mt bi lp trnh c bn ta s i tm hiu cc thanh cng c ca chng trnh. 2.1) Thanh cng c ca MPLAB IDE:

a) File: Di y l cc mc menu trong trnh n File. New: hin th mt ca s son tho mi.Khi tt n s bo cho bn chn ni lu file bn to.T hp phm Ctrl + N Add New File to Project: Yu cu mt tn cho tp tin mi trong hp thoi.

Tm hiu MPLAB IDE v8.56

GVHD: M Duy Khanh

Open: m tp tin bn lu li trc . Bn c th dung t hp phm Ctrl+O. Close: ng ca s lm vic, n s nhc bn lu li nhng g bn lm trc khi ng li. Save: lu ca s son tho li. Save As: bn mun lu ca s son tho mt ni khc vi mt tn khc. Save All: Lu tt c cc ca s son tho m vo a. Open Workspace: M khng gian lm vic mi, m khng gian l khng gian lm vic trc y . Save Workspace : lu khng gian lm vic . Save Workspace As: lu khng gian lm vic vo mt ni khc m bn mun.. Close Workspace: ng mt khng gian lm vic tr li cu hnh mc nh khng gian lm vic lc khi ng. Import: nhp mt tp tin g li hoc hex vo project ca bn. Export: Xut ra mt tp tin Hex t Project ca bn. Print: in ra thnh vn bn. Recent Files: Hin th mt danh sch cc file m . Recent Workspaces: Hin th mt danh sch cc khng gian lm vic m. Exit: ng tt c cc ca s li.

Tm hiu MPLAB IDE v8.56 b) Edit: Di y l cc mc menu trong trnh n Edit.

GVHD: M Duy Khanh

Undo: o ngc nhng thay i cui cng thc hin cho cc ca s ang hot ng. Khi khng c hnh ng chnh sa li li, lnh n c chuyn sang mu xm v bn khng th chn lnh. Redo: o ngc tc dng ca cc hot ng Undo gn y nht trong ca s ang hot ng. Khi khng c chnh sa hnh ng lm li, cc lnh menu chuyn sang mu xm v bn khng th chn lnh. Cut: Xa vn bn chn trong ca s hin ti v t n vo clipboard. Copy: Bn sao ca cc vn bn chn trong ca s hin hnh lu vo clipboard. Sau ny bn c th dn cc vn bn sao chp vo mt ca s MPLAB Editor, v tr khc trong cng mt ca s Editor MPLAB, hoc vo mt ng dng Windows. Paste: Sao chp cc ni dung ca clipboard vo ca s hin hnh ti cc im chn. Bn ch c th thc hin thao tc ny nu clipboard cha d liu nh dng vn bn. Delete: xa on vn bn chn. Select All: chn tt c text and graphics trong Edit window. Find: M hp thoi tm. Find Next: Tm vn bn tip theo. Replace: M hp thoi thay th. Find In Files: M hp thoi tm trong tp tin. Go to: Ti mc quy nh ca hp thoi Go To.

Tm hiu MPLAB IDE v8.56

GVHD: M Duy Khanh

Advanced: Nhng c tnh son tho tin tin. Bao gm la chn vn bn u ch hoa hay (ch)thng , m bnh thng, hay indente hay lm lm xung vn bn. Bookmarks: Lm vic vi bookmark. Chuyn i mt trang nh du (lun phin cho php / v hiu ha mt trang nh du), i cc du trang k tip hoc trc hoc v hiu ha tt c cc du trang. Properties: M hp thoi Options Editor. c) View: Di y l cc mc menu trong trnh n View. Di y l cc mc trnh n trong menu View. Bt k mc no khng p dng i vi cc la chn thit b s b v hiu. La chn mt mc trong trnh n ny s lm cho mc hin th trn ca s. Project Window Output Window MPLAB IDE Toolbars Disassembly Listing Window Hardware Stack Window Program Memory Window File Registers Window EEPROM Window Memory Usage Gauge LCD Pixel Window

Tm hiu MPLAB IDE v8.56 Locals Window Watch Window Call Stack Window Special Function Registers Window

GVHD: M Duy Khanh

d) Project: Di y l cc mc menu trong trnh n Project. Project Wizard: s dng Project Wizard gip bn thit lp mt Project mi. New: m mt Project mi trong khng gian ( ca s) lm vic. Open: m Project c trc . Close: ng project trn ca s lm vic. Set Active Project: chn mt project trong ca s lm vic. Quickbuild: xy dng mt As dung MPASM m khng cn to ra mt project mi. Clean: Loi b cc project trung gian, chng hn nh hex, i tng v cc tp tin g li, cho hot ng ca project. Nhng tp tin ny c ti to t cc file khc khi project c xy dng. Build All: bin dch chng trnh. Mt project phi c m trc khi iu ny mc s xut hin. Make: Xy dng cc project bng cch bin dch / lp rp cc tp tin c thay i k t ln cui xy dng. Mt project phi c m trc khi mt hng ny s xut hin.

Tm hiu MPLAB IDE v8.56

GVHD: M Duy Khanh

Build Options: Thit lp v xem cc tu chn cho cc project ang hot ng v tp tin c nhn bng cch s dng cc ty chn Build. Save Project: lu project li. Save Project As: lu project li mt ni khc. Add Files to Project: Chn cc tp tin vo cc project ang hot ng. Ty thuc vo loi tp tin, MPLAB IDE s sp xp cc file vo ng loi trong cy ca s project. Add New File to Project: thm mt tp tin mi vo project. Remove Files from Project:loi b mt tp tin t project. Select Language Toolsuite: la chn ngn ng phc v cho qu trnh lm vic. Set Language Tool Locations: Thit lp cc ng dn / th mc cc cng c ngn ng bn s c s dng trong project. Select Version Control System: Thit lp cc project ca bn s dng cc tp tin t mt h thng kim sot phin bn. e) Debugger: Di y l cc mc menu trong trnh n Debugger. Select Tool: Chn mt cng c g ri. Mc nh l None. Clear Memory: Xa tt c hoc ch mt s loi b nh MPLAB IDE c s dng trong project. Basic Debug Options: Mt khi bn chn bt k cng c g li, menu Debugger s b sung la chn sau:

Tm hiu MPLAB IDE v8.56

GVHD: M Duy Khanh

Run: Thc hin chng trnh m cho n khi bt gp mt im dng hoc cho n khi gp lnh ngn chn.Qu trnh bt u t truy cp chng trnh hin ti cc v tr hin ti chng trnh truy cp cng l i din nh l mt con tr vo chng trnh b nh ca s. Trong khi chng trnh ang chy, mt s chc nng khc b tt. Animate: gip cho trnh g ri thc s thc hin cc bc trong khi chy, cp nht cc gi tr ca s nhp d liu. Chy chm hn so vi cc chc nng Run, nhng cho php bn xem cc thay i gi tr trong ca s . Halt: Ngng (dng) vic thc hin cc chng trnh m. Khi bn nhn chut ngn chn. Step Into: Cc bc thng qua cc m chng trnh. i vi cc m assembly, lnh ny thc hin mt ch th (mt hoc nhiu chu k hng dn) v sau ngng. Sau khi thc hin mt ch th, tt c cc ca s c cp nht. Step Over: Thc hin hng dn ti cc v tr hin ti chng trnh truy cp,thc hin cc chng trnh con c gi v dng ti a ch sau CALL ny.Nu bc qua qu di hoc xut hin treo , click ngn chn. Step Out: thot ra khi chng trnh con. Nu l mt bc thng qua cc m chng trnh con, bn c th kt thc thc hin phn cn li ca m chng trnh con v ngn chn theo a ch sau chng trnh con CALL bng cch