lnuLx 1. lnLroducLlon Lo klel 2. SLarLlng a new pro[ecL ln klel: 3. CreaLlng a source flle ln C 4. Addlng source flle Lo Lhe pro[ecL 3. CeneraLlng PLx flle from C flle 6. Same Lhlng wlLh assembly language 7.ls lL over?
4
1. lnLroducLlon Lo klel
Machlnes can noL undersLand human-languages and Lhls glve rlse Lo Lhe requlremenL of compllers. 1he formaL whlch can be dlrecLly undersLood by 8031 ls Lhe PLx formaL. So lf you won'L your 8031 Lo do someLhlng you musL have a Pex flle. 8uL whaL abouL humans? Pumans also don'L undersLand language of machlnes. So we humans wrlLe Lhe program ln some hlgher level languages such as C, !AvA eLc. we can be undersLood by us Lhen we use a compller and converL lL lnLo a machlne language. CLher opLlon ls we can wrlLe our program ln assembly language of 8031 (whlch ls also human undersLandable) and Lhen by uslng an assembler we can Lurn lL lnLo Lhe machlne language. WhaL ls kell?? Crlglnal name of Lhe sofLware ls kell mlcro vlslon. klel ls Cermany based sofLware uevelopmenL Company whlch provldes many Lools. klel provlde followlng Lools for 8031 developmenL: 1. C31 CpLlmlzlng C Cross Compller, 2. A31 Macro Assembler, 3. 8031 uLlllLles (llnker, ob[ecL flle converLer, llbrary manager), 4. Source-Level uebugger/SlmulaLor, 3. vlslon for Wlndows lnLegraLed uevelopmenL LnvlronmenL. 8uL Lhe quesLlon sLlll conLlnues whaL ls klel??So klel ls baslcally a cross compller .so leL's undersLand compller and cross compller. Compllers: Compllers are programs used Lo converL a Plgh Level Language Lo ob[ecL code (machlne code). ueskLop compllers produce an ouLpuL ob[ecL code for Lhe underlylng mlcroprocessor, buL noL for oLher mlcroprocessors. l.e. Lhe programs wrlLLen ln one of Lhe PLL llke 'C' wlll complle Lhe code Lo run on Lhe sysLem for a parLlcular processor llke x86 (Lhe processor whlch ls lnslde our compuLer). lor example 1u88C C ls very wldely used compller for c language.ulffrenL programmlng languages have dlfferenL compller. 8uL keep ln mlnd LhaL a compller refers Lo a hlgher level languages such as C,pyLhone,pascal,!AvA eLc. where as assembler refers Lo Lhe assembly language whlch ls a low level language(noL machlne language).
3
Cross compller: So Lhe deflnlLlon of cross compller ls a compller LhaL runs on one compuLer (x86 processor) buL produces ob[ecL code for a dlfferenL Lype of compuLer (8031 and derlvaLlves). Cross compllers are used Lo generaLe sofLware LhaL can run on compuLers wlLh a new archlLecLure or on speclal-purpose devlces LhaL cannoL hosL Lhelr own compllers. Cross compllers are very popular for embedded developmenL, where Lhe LargeL probably couldn'L run a compller. 1yplcally an embedded plaLform has resLrlcLed 8AM, no hard dlsk, and llmlLed l/C capablllLy. Code can be edlLed and complled on a fasL hosL machlne (such as a C or unlx worksLaLlon) and Lhe resulLlng execuLable code can Lhen be downloaded Lo Lhe LargeL Lo be LesLed. Cross compllers are beneflclal whenever Lhe hosL machlne has more resources (memory, dlsk, l/C eLc) Lhan Lhe LargeL. kell C Compller ls one such compller LhaL supporLs a huge number of hosL and LargeL (lncludlng 8031, avr, plc, arm and many more) comblnaLlons. 2. SLarLlng a new pro[ecL ln klel: 1) So, before sLarLlng wlLh klel l recommend you Lo make a folder ln whlch you gonna sLore your enLlre work because worklng wlLh klel wlll generaLe number of flles llke ob[ecL flle, 8Ak flle eLc. now here we wlll see how Lo wrlLe Lhe program ln C and assembly, how Lo generaLe PLx flle. ln Lhls case we are maklng a folder called 'bllnk'. 8ecause our program ls abouL bllnklng Lhe LLus connecLed Lo porL 0.
2) now open kell sofLware by cllcklng on sLarL menu Lhen program and Lhen selecL kell3 (or any oLher verslon). l am uslng klel3. lollowlng wlndow wlll appear on your screen. lf you have [usL lnsLalled klel Lhen you wlll flnd hello program on your screen.
6
3) now Lo begln our bllnklng LLu pro[ecL. Cllck on new mlcro vlslon pro[ecL.
4) And Lhen you wlll be asked Lo provlde a folder for pro[ecL and pro[ecL name .We wlll use 'bllnk' folder whlch we have made before and wlll use 'flrsL' as pro[ecL name.
7
3) now you wlll be asked Lo selecL chlp and chlp manufacLurer .here l am uslng A189S32 so. flrsL selecL A1MLL and Lhen cllck on (+) pulse slgn near Lo lL so lL wlll expand and Lhen selecL A189S32.
8
6) now you wlll asked Lo add 8031 sLarLup code Lo your pro[ecL. .l doesn'L know abouL Lhls 8031 sLarLup code buL lf you cllck 'no' lL won'L make any dlfference. And lf you are uslng assembly language for programmlng you musL cllck 'no' lf you won'L Lo avold some warnlngs. 8uL Lo maLch up wlLh many oLher LuLorlals on neL we wlll cllck 'yes'.
7) now you wlll geL followlng screen on your compuLer. Cllck on Lhe pulse (+) slgn near Lo 1argeL1 so lL wlll expand. 8y double cllcklng on S1A81u.A31 you can read LhaL flle.
9
3. CreaLlng a source flle ln C 8) Cllck on flle ->new Lo creaLe new flle. now you wlll have a blank screen ln fronL of you. ?ou can sLarL wrlLlng from here.
10
9) now wrlLe Lhe program ln Lhe blank wlndow. Conslder we are uslng C language here.
10) AfLer compleLlng your program cllck on flle->save as Lo save your pro[ecL. WrlLe 'flrsL.c' ln flle name. We are uslng .c exLenslon. ln assembly you can use .a31 or .asm .now you wlll flnd colorlng LexL on screen.
4. Addlng source flle Lo Lhe pro[ecL 11) now we have creaLed a flle called flrsL.c" .8uL sLlll we have Lo add Lhls flle Lo our pro[ecL. 1o add Lhls flle Lo our pro[ecL, expand Lhe 1argeL1 Lree menu by cllcklng on + slgn. 8lghL cllck on 'Source group 1' and selecL 'Add llles Lo Croup' .1hen glve flle name 'flrsL.c' and close Lhe
13
wlndow.8emeber lL ls noL necessary LhaL you wrlLe enLlre code and Lhen add flle Lo pro[ecL you can [usL add a blank flle Lo pro[ecL and Lhen sLarL wrlLlng Lhe program lL won'L maLLer .
14
12) now you wlll flnd flrsL.c under 'Source group 1' means flrsL.c" ls added Lo our pro[ecL.
13) now lL's Llme Lo debug our program .so cllck on Lhe" 8ulld 1argeL" from pro[ecL menu or cllck on 8ulld 1argeL buLLon .?ou wlll flnd some acLlvlLy ln ouLpuL wlndow". AL Lhe end of bulldlng process you musL geL message 0 Errors (s), 0 WarnIngs". f your programs have any error kIel wIll gIve "Target not created". You have to fInd all errors and correct It. You can avoId warnIngs but you must have proper reason why to avoId them. After thIs every tIme you edIt your program you can just clIck on " rebulld all 1argeL flles"
13
C8 1PlS
3. CeneraLlng PLx flle from C flle
14) Ck every Lhlng wenL flne buL where ls PLx flle. We do noL have PLx flle. 1o creaLe PLx flle cllck dlrecLly on opLlon for LargeL" buLLon or from Lhe pro[ecL menu selecL opLlon for LargeL
16
'LargeL1' ".?ou wlll flnd Lhe screen as shown bellow .All you have do ls ln Lhe 'ouLpuL' bar selecL creaLe PLx flle" check box and ln Lhe 1argeL" bar flll xLal speed for your conLroller. l am uslng 12 MPz. noL necessary Lo do more. Cllck Ck.
C8 1PlS
17
13) now cllck on rebulld all LargeL flles" buLLon. ?ou wlll flnd message creaLlng PLx flle from 'flrsL'." ln Lhe ouLpuL wlndow.
18
16) 1haL's all. Co back Lo Lhe 8llnk folder you wlll flnd flrsL.PLx" flle Lhere open lL .1hls ls whaL your conLroller undersLand. Cur PLx flle ls ready Lo be burned ln our conLroller.
19
6. Same Lhlng wlLh assembly language CreaLe a new klel pro[ecL as descrlbed above and Lhen wrlLe Lhe code below(noLe:ln assembly when asked abouL 8031 sLarLup code please selecL nC" lf you wanL avold number of warnlngs):
SLore Lhe flle as flrsL.a31" or flrsL.asm". 1hen add flle Lo pro[ecL and Lhe remalnlng Lhlng ls as same as C. 7. ls lL over? no lL ls noL over. We have seen very baslc operaLlon of klel. 8uL klel ls very good sLlmulaLor Loo. uslng klel we can analyze reslsLors of conLroller, whaL ouLpuL we geL when we glve speclflc lnpuL, we can monlLor speclflc varlable ln our program by addlng waLches, also by uslng loglc analyzer we can see Lhe orlglnal slgnals. lor all Lhls please vlslL our blog.
lor any suggesLlon or query please Lmall: arLhlndla47[gmall.com or pandyaelecLronlcs[gmall.com lease vlslL our blog:
21
pandyaelecLronlcs.blogspoL.com We are also on facebook.