Вы находитесь на странице: 1из 127
od Coit) ah r a PM rect a cols ea betes Newnes + Sirmuscsce shaaont Se? TONG ‘nee Hose Jha Hl Ceerd OX? DF 225 Wood Ave, Wor, MA 1801-281 paid 2002 Copyright ©2602, Jo Monon. Alien assed in accrdance sth the Copynght Designs od Pate Act 1906 Nop fein my eden mater am ig occpsng ting ny mean Sesto mss tet Ok ‘sty mn ow oat hee Gynt Dee don 9 er om ree ed ‘Cori Lang Agen 90 Ton Cour Ran anc. Engle ‘rah Libary Cataloging in Plein Data ‘AVR on assay cue 1 Progammate canalies 2, ngnted teu —Design and ensetin 2° Mires, ie e689 san 075065619. “ype Ave pee Bail Ay Becks Peds Gre Btn by Bie Li Girt 0d King Ln 2 asi Opes Contents Acknowledgements Prete 1 Imodscton Shar bit foe PIC uses Namber sens ‘Adng in iay Negate nantes An Ei Flash ecole: Ine pepe ‘Shoosng your nods Roveian Assenbting Reiss Inston: Program tmplae wth ATPOSI200 and Tiny? Program LED . "AVR Suis Ascbing ‘AVR Seo — Stns Ealing Hrevae AVR Si Progam Fase bee ee Progams Band C: Ph Buon Seven Semen dpi an inc aden Programs dE Comte * ‘ing Progam Fi Caer “Ting witha ater? ‘The Progam Coote and Subotioes Progam G Counter 3 z wae : oar ee aE Lape Ga Silo PerEG te Suna Reser ‘Warhiog Tine Sle a ser ropa reine Comer 3 loosing ee ret ofthe family 4 ntermedat Operations crs Program K Reston Teer ‘Aroue Compara Program 4 aaogu dg coment ort aalape to isl cameron DC) "EePaoM Testi menus Inpat Copare Otip: Compare ‘aor Program N: Melody Maker 5 Advanceé Operations PWM Pub dh Modulation 0: Keytoud Ci Program Converter ‘Sera Pepe tae (SP) Shree AA Nea Sumnaty Fl Propum F: Computer Conte Robot Concho Appenti Speifiations for rome FICS Pin aout of various AVR Itai overview Instoction star Inerupe vector tables ‘nen al a fl red hs 9 2 15s Isr 16s 1s 16 Appts: Contacts ad farther ening ‘Append J: Sample programs "row A Leduntum sp LED on ‘Progam B, Push bono (1.9) ~tae x LED on when but ese rogram Pus buon (2.0) shore veson of puch tn a0) rogram D, Coumer(.0)~ cous push buton presses on seven sepnen diy Progam E, Coumer(2.0)~ as couse (1.0) eéuces mukiple ‘ropam F Chaser cases LED sla vara pede ‘Program G. Couner (3.0) coater (2.0 with Baan feu saies rogram Tai pdesran roti Wa i ior Program Lape gas ~ simulates eight eer le ps Prapam J. Fegueycouer~mesnses frequency becet and Program K, Reson eer = ssces human tion Program Lr anlgue ol errr Rofo make & “oar ap ADC rogram M, Negev errs Vint (SV) Program N.Meley maker = ply rostral one ‘eogm O, Reva comer tars Your compu: keboad ‘names oe Progam Capa contd ab mn me vs 130 1 ae 20 206 aie ForTar Acknowledgements Reber Care fi inuodaeed met AVR, ad 1 auicly cone their feng oer ther miro The ony nie weet Se ‘env lac ane athe le ofthe Missin Pc. for example. nei wa ony 3 ater of ine blr this woud tay overcome and ts bok agi for those with te oro meron backround ssi AVR, Toul eo ke hi oppomuni wo thank tase who have sed me with nat you te tefere 300 Atmel Uk Kindly dented sal ft ape ‘nt thwgh seo emai ypc. ad bev! Agha st 9 Mat esp for hs eflent pd melo proteadig whch fen Stasi of wetng What nl eer the pape. ely hd mac Bete ‘ngs oo. fr eagle sing ie Ul i il managed 0 ear mal eyo cmb teygh my ges | woud ln eta ant Ricard Gers for Isdupgesion of sample pet bad gnealdee Tonk Ma Harta Seri atp wih shen esa ier align Ray CColege of Art Fly | mst tank Max Horsey for bs pet Beery Stace apd advice, ad athe Besos Onprient Rasy College, imply for cone use afte sll John Moron Preface Coagatlans By reading his you showing ap intrest in ont of te mos ‘Spates vesae 1 micocoarele o the marke ke AVR. Cote Tending his okt la aout he entre AVE ay nd ho’ hye ep Simpy the design of your elton projets a wala all you 0 crete trashed prt, Lie all metosonalles, AVR allo tore luan whic retain st she same tine comply ele However, AVR ar eer ft teat» Ae cocoon theme eal ne Sesgne' i book Tin fa he mar bes pricier of meron programing, uch a nay ané hexadecimal and cove the pin ses i deeaping program. -ESSHAVR topes mare sense one wey ret evap ck Ibelae pedstenroneng Smale mely sen ques Comers ‘nd compuersonislled a “Totegin with he progam arly developed fr you. hover 38300 ropes though each cgay mare ed mere fhe peas wl be writen Erion th form of te eres, ich appear troup! he Sook wi ‘ions pie ate ed fhe book Te apes smmarae ee Pop” frie of the ost ppar AVR loving qk Tfetece without hein to ‘aug tuough pes of cnuees Thr is Book oes hans approach sing to rogram AVR. sed lil poise fl soe of ifooatie for AVR programe ole Mortoe 1 Introduction ‘An AVR i type fmiioeonl, nd no jay room ~ AVR fet some of he fe sound Ihe oak of a merce a 9 dese Tap of tzon wih smsene pent wie pthing without but set ‘suthing wh he pea hat you wre Under your anne» penal [age coments! eeu ca be sqiszed into on pros thes nto oot hp. Miroconteles be the gapbebeen hrvare ad software they Fab ‘ogra, urine your sips yey a say Sense Ser a ak Inert withcomponensin a reat Ovrthe yer thy ve brome onde bl at ofthe lon of lsc! ergot ents hey re [rex or experimenting sl bath podcast censie Fey of apravon egies iar sen he epi deep an AVR poss, 2 lnaduton ‘The AVR family coves a buge age of diferent eves fm Tiny Sp doves to toe Megs 4pm ep. Ove oe fas aings about hi it Sou'san writs prota with ene ype of AVR amin a ten change Yur Tin and pre ropam ia Geren chip wth oaly muna change Furthermore wes yo lear how oe one AVR, yous eal ari How ‘ee them al Ea a pecans he own Ses eres = ‘oderenh hey be common fea. Fudan AV programing lo do with pasting sound nambers ‘Tie wick orogtamanng sefeeern making te chp peor the de red tak iy the snl movement ad posersng of nutes Thee et Specine staf ws ou are allowed fo prone on the mbes ~ these ae Shed inaction. The program sige, gee fsturion, ans ‘ore compat oes which do ore pect, The enip wi sp gh ‘hes incon one ty ane, peroine milion every son hi Sen ‘om ie fngeny of tear rcoenesed 1) and hy perfor ob The nme inthe AVR nt 1. Recdve rm inp ese a ip ‘oe’) 2. Stredin pei comparment siete Chip 5. Procased eg. aed subtracted ANDed alps et) 4. Sent ut ough ose. sigan expo Thi ese al hee it posamming ren You mi te inking Foren thee ae cern ote eel fens tht he AVR rosso with sucha on-board cre eral messy, malages compas and ost of ag wich nde wheter ora somthing patos happened ‘shih mae ie lot aber "We wil tein y loci some bse concepts bend mleocenrties snd uly bein some expe rejecs a Be A790ST200 (hich we lel 5200 fe sho) and Tiny AVR Then imermedineepersons il ke ite lace with be astane of moe adtance hip (veh be ATROS2315, Finally some of the more advanced Snes il be diced. Wh fi oj mcd aod he 2513, Mat ofthe poet cn een acd ft ny pe Of AVR, 20 tere nen for ou go ots bay le ode Short bit for PIC users ‘A large munber of ender wil be familar wth the popu PIC misc tole or tha reson meno bly bow AVR an fea pen! {PLCs For owe of you wh don ow Wat Ps re, Sn ry to 2 $f yo dn det lh il ll ak ee aero) Basel te AVR are based on «more rnc undying architec spd an exc an insti every lsk far apse FICS ich sie ane ory ow cok ples. So forthe sapere Ben, ‘AVIS wl on for ines sf Farther ey aso fer 3 wake” Inroction 3 ‘es Compared wih eon tt PICs hve), and sto te ins a may Instn, pogams wil in snaps te shore tr neh mo owe tt aoa dnatbertsboas 90-120 isu eet cake gale rpettin an ean. dm ny iw De eae ine 50 ‘sive neocon Further, wt are known 85 pci inti eisers op PICS (and ‘novnssnpdospaegiteron the AVR) en ret ssouand ook fs (4 3c wie dsp eri tcf eee toe {tei AVR. Hwee the mio ule and AVR pope emo eficin onthe whole AAVRS he Rash peptone ‘Se reriten repay. an finals 3 te ere Pics ve aoe coed ve 2 pia Of mas yes tea sme among Comping hae, Seoveenae model wh the AVAshve mange te odes Be Number systems worth itch sue he ren numbering sates which ae inal m 7 pvammi, ban inal nd hens 4a dumber see Zuber (ere ae oly eps af Si (Ose ‘posed dena “are 0th Wi ieee 101M Coes ho inal pens tre Toso sien dgsies 2 Ses eek 5.A08.C°0.Eand Fi The wleblwshns hori ot ug tc dco Bian gk) dca ign tenascin 2g ‘coouone op ONS aes 2. ‘eooonat on a feo000i0 oo a venoms cH S 0100 foe si oes & 00110 bos Sooo fo a seoni008 ‘0s & ftooreer 0 6 sen bis a fooorant on 2 foeor100 a fo0ori01 a > ae te? os % a ” The nny ig (or i fade ih ow a et sit Short cd ues O(terenss te mmieog su fom mt en 1" Sune es Bid sow te ner ef wate mane One eqil Sie tw (2) ee mb of Po Soe Sey tes emake! fod sot Naw te = Salar OR whe be amber carnods be ome of re Stic bnew et meay ps Sean eh an vey Sher degoe) seqnee sft bb ern nse Toile an Eat wrcg bv? obec fate) on are mote ‘ch So Ce ou sain mands in imo ol lok fr pes pone’ oft sare sera ea oy on Example 1.1 Work ote ary egal of te devil munbe 3 Lape per of eat tn 63 = = Bule= 1 Fheiewer SS 6h 192 prentrthan Iso 5 =, Tole lee tun 9b Speen 508-6, Tate 500 Thieves 1816 Thirteen 3-2 101011 ite binary eu. “Ther bone a akenatv (8 moe se method which you may find aster Take th denial nabs you war o comer and de byt IF Therese reine fee (eer an 0 ime, we Sow 3 oe Then ‘vide hee and ote same wring the reminoe toe Jo of te revue, el you end up Sng one by te, eas 3 oe. Example 12 Wa ost the tnary equal ofthe ein umber 3 Troon 5 ‘Lewis, it ofa heradeinalis the amber of ones (168= 1) an bit ithe umber of 1 (16= 16) ee. To conver dena o bexdeenal is ofes brevis’ Hook at how many Tee het ine namie ad ow anyone ‘Exomple 13) Comer te decal munber $9 ito headeinal, Tere a3 16 i 58, ewig $9 ~48= 11. So bit is 3.1 eB in Haden 0 ‘sB-Themunber therefore 38 [NERCSE 13 Fin th ecdecimal eu! of 19, [XERGSE 14 Fin ie beadecinal eu of 10, ne ofthe wef hings about hexanal, which you may have picked for Ener Lt wasn ent Wit ny I you eat op ‘ory number in 4.5 props (aed ml, esl ne), ee ae ‘ops canny bcd no ei nme {4 Cone 010100 io eS ent ine bes 119 ett scare twos aets our fs preg. "Aber he deal headings, tere 2 sce 1 pesiy some deletions “ese are your oon ais fo the ster nso dtnay = yo ppertnieto ive ore uel es 0 tbe egies you wl ewig Pat ‘ple | sey sea working reper cle temp or oil rks ad ve ‘Sine his ame to RIG You can cfine he names ofthe waking reine Sng the def dete, sho phe ensue. Anca peo dee tdarcan beso gencrly ga nomecal value to word equ Tis a2 {evan to ge your own mamas 0 0 repiners Fr ample 1 righ hve ‘Storeted a sve pram dpi os of Por nd ected hat | is 0 evict wre DupleyPon wien teferng to Por. Por is rep mer OI might wre Dla ne prop snd he assem wl inert as Pr Re Dipper = si Another example of where this ight be wei i whee 2 paricarmnbes {Sed at eet pins nthe progam, and you might be experimenting and ‘Sanging thr mabe You could we he oe deve age amet eae ae Induction 21 ‘ues and singly refer the ame inh st fhe program. When sou then 90 change the mmbe you nod any change alee eq he, ad atin alte instances of he se ofthe msl ovr he prem, Fo the ‘moment, homer, wilt be ula te-eqe cece, ‘Air i declraons, we be the ft ie ered by the ehip on pone: ‘pares In isin ge jumping to seton calle Init wich se op al he nal seine AVR Tas ues the mp eset simp nit 5 ‘Toisas or sae ump. a ote words akes he chip jmp action the progam shih ou hve ables Ink The eso wip i's scene ‘amp iin he wave assembler ieee nso and srs ‘mira net Ser cn th escent instar father nfm rp Tat ine the smb nl) mer (ie in wis ump lr 40 ncn some th vga Banay sia coert tn ofa ph ming esp of etal con ts hich ring a pus a wich opts This done wing th Bos Deston 1 see ‘DORB and BORD fach bin he reper crespone spit ne che, For esampl ti of ODRD cersponds opm POLané DES er DORD Ge sponds po PDX Now sting te se DDR bh was oe Sy ‘utd makig he bith ese in es IF we config pin asa inp then ne tit eption of seeing wheter te apt hs bikin play resist mot Tie may ane ooh ‘oul of hing nleean exer ser In ore temas oe alan, sake the elon iin PORTS ih however ou do nt woe make Srey ae em by making eran Sin PORT For tc oa ‘We want begin wi he ou in some sor fsa sate ea of an 40 forth cu is, mak hereon bn PORT high soe doping ho you wish th St Aa tase shoul ce ngs up. sample 1.19 Using» 1200 chip, pns PEO, PB and PBT are connec Yo as bors. We would ike pull an PBS apd PRY ony Pas PDO 0 PD 2 Sse an seg pin and al er pie mo cone ‘All pas shoud nly be of What ourbers soul be writen to BOR OKO. Fo nd PanD to corel speiy he atone of Ge AVES 2 Fo nt ng nop 7a 4d 7 we Le Sse a a he tne in Be ESS Sift ae SSS haga SRE ee ste fr Dono waujangee ae ere es ny mate Pt angie Bg PoE 22 tnnscon ver opt nlf oh ume fr Foti 041021000, i ‘puss ofr Por, a heme fr PortD is 000000. ‘ie cant move these namber dace ino the LO reper, a ns v= tae ito ove ther nt wong ester (cha temp) ad hn opt the worn einer the UO reper Ther es mabe fy ween al rege number; ‘This aad be medi maber isos eis, Du i very inperano ape tat his nsrosion canna be ed onl wang reiers~ nf on ae ‘ano Al ondR3 (we an heroes uso temp. shat 216) We hn alt ue nl faerie intracton he pb ne who ‘move Se ye happen abe Oo 2890xFFEBITII 111 regen : “This lah ete of regiter noes nts) = nate a vane of| {hi oer sa co epee on ll wong Fete Falls see register : “This the coments of ei roves 2504701111111 to i gh Tike infor on res Dreo AB ond 3 "Ween ee ove emp ine te 1 reper sing te elon nr ot foregret “Tis move aber out fom epi in an UO reir Make ae You sete dr of te open he naron =O reper fis, working ‘zits secede opt her the ong way rowed! We can Derefrt eet tee esa the Lal Sen move sunrise DDR, DDRD. Port and FortD v8 temp [xAROSE 113 Using 8 1200 ein. pn PROS connected apres see: ‘td pins PB, PB and PBS conta ed yellow and seen LEDs peste ode PDS cary Spas anifred tater sod POY-PDS cay ils from a ngs veeves A te pits ae ht connected Al up Sl inl be of nd PBO soa have pulp ensbed Wate eg ies at wil me pe lat ect or i rogram Aer ising teat sce propre nthe main od of Be ‘rogram labled Stare. Thies ware lof he rogram il ie Note a _ avedacion 23 ‘bemeprm endear Stt Keeney loopback {eStar batt esha ling tonerng soon may ea ae ise ine cog. teed ofthe ogra an wie ean theassenble top steenng he ie bo a cea ar tl op ssembing anya oc i retches teen fhe 2 Basic operations with AT90S1200 and TINY12 “Te be wy ear ia rough exe ad by doing hing ous. For the ‘ex the book we wil ove example rjc ay of shh i Dees ‘rien by you Fortis work mon elect it blpef you sly ese Feprams, wong them ets you go along ia Need or whatever develop. test everett Youre sng Codon have ary sell AVR sofware ‘hemamene you can il wee he rosa oun Nepal of hem st, ‘ist ofa copy out he ror emp Sveed te previo ape scjosing iar you se fe nd se Kas templateasm If Jou ate ting Notepad mae sre Jou Sees Fie Type dy Fle The asm ile exten ref tans souce- ie ht wes wil be asec Program &: LEDen, + Conring cups ‘fies oe popams wil se he 1200 ep Lend up he emp Sov As ‘oe the igi! template unchanged and eal he ie edo as. Make be _agproprtesdjosmen he hese te celevan fe 1200 chip (eae itvice, an Inde) Tis fr program i Simply ping trn oe 2 LED ‘tn icey no Toe St ep 0 sgn net ond tps Far ns pce! ‘rl pa eal one opi td will onest ta RB. Te seen tp inthe ‘sion eth flowchart, Te shown Fgura weer ae ‘Sr progr. The a ok Seu) peta Ite rine You sald Sethi con ti scone enemies fo a cme ake ian ot Prure2t Basle opetons wi ATHOS1200 nd TNYT?_25 The cond Uoximalwsfuning om Be LED. which eat make A high which meats Seng bi U on PORTS to | Todo it we cull moves ume ifm, angen moe tha umber i Pres However here 3 ‘hors. We ean ete alow insect sol teregbie “This seo an VO ete Alivough you cane mov a nome ety (moan UO reper ou cn stander is some he dil “ou co sand ear nda bitln UO repos 32-43 (90-S3F fa te Forna Pom (518) dined al the FORT ad PING rests ean De anole seas Tego nseetin Gr laing i Be eat ore bi “This ean» bit in an VO reper, hous ree i ny we oe UO {eyiters 231 Far cur pita pletion, wwe wa ae Pot and ‘So we living iron 3 he pit abled Stare Start sbi part sturms om the ZED ‘The cx in is imp stare loos ack t Stare ‘This mean he chip wl bina ide oop ering onthe LED. The opr sab ready te snes, Yo an chest u've done ery ‘init by ckng ate complet pros Appene under Prgrom 4 All subsequent propos wil be pened ine ack the sme wae wil ‘ow ase he propm bt you dont ave he ran sts ja read Throveh ie fet secon You sos domtioae NVA Sue fom hse ete {srwv-sume com) fre a tie | eer. Tir esl mols nd (th ript hard allows you 6 propa te AVR chp AUR Stud ~ assembing Fis fal sd AVR Si Ste Pree ew Pec and het ine (Co Cebu, got s eli eon td che WN rae ‘Stumble ps youn he sec les ne ee fro ohne ics easy he asad you wre ‘SUEEn Dinero Rp ch or Asuy ern te Res Wino ‘bce Ni Fok you gl eed LEDonaon el ito [Nonor ese nS je Wino Now pn Fei rj ‘annette wil Cesc pe a fe od oe see 26 Basle opoaon wth 1901200 ond IN? assemble wih no errs. ear at produced you wil i Bef amin the Li Fle Land hsp i Notepad Sone eter tx ee fo san the doen freer, lets spl progr 8 pobabyaing shore thn sapeling mile, Core any protien! od then shave 9 Testing ‘Tare re tres in way tet your program 1. Somuaing 2 Enlai 5: Progamming on anal AVR and png ne “The fst of et, simulating, teil sate bse A piece of sae etende ik an AVR snd shows ou ho Dts the progr Would ra ‘owing you low he repr oe changing ete You can io pretend get Japa ty manly chaning te manberr PINE se You cn ge 200 te ‘sf whether or not he ky eames bing Your progr wi Work th th Und of testing bt air reer fsa woh bun-bonee can! tered Atmals AVR Sinultar oer ith AVR Ss, AVR Studio = simulating ‘We wi now hie a ao Smale te LEDon rer. Nits You seme pour as i, double ck exit inthe Poet Window to pent Soe of ute he op of the sren should at Become ace, There a ek) tong volved in sepping hugh yor program. The os wef one oF ‘here, Bi led Tce Ina or Sip ne. Tha ran the este le of yuk opi reing this once wl begin. salon ad shule hal th Feat ie of your pram (rp tou ean thc baton Co is ‘shoreu FI soap deo our progam. We sil ee the impanc fe ‘ter sping bares when elk brie ner on nthe boo rr for is smaion ol hing wel ened lok how He reer re cheng prc Uf PB). Tis en be done ‘plage Views New 10 Vin. Yu at state reper fave ee [7oupe it eaepaies. spun te Por teers aos showe 900 te For DDRB an Pin reper, You can lo vi he working reps ing t View "Regier We wil ewosching 216m pai, 8 ‘emp, Avot wef shrcts reba, BB (SN + FS. on tee Sepyng ough yor progam. Nace bow temp gets ced 2 Por a FerD ae sl seared to 00, then temp i ded wh OFF (GELII1D, which i hen sied in DDRD wed DOBD. The (sal) |, Pe, Bit 0 Seas shown by the tck in the appropriate box. You tity notice ‘Bosle gperaiens with 79051200 end TNYTD 27 ow this wil asomacelly st Pn i 0s wl. Renee the dierence ‘enveea For and Ra Paria Yegiser represen wha ou ms 0 ‘ua trough the pes nd Pn etesent th eu ps ea Be Sine For ena, you cold ty ta make a np high here pn 2 ‘Expaly shored wo pround~ Po woul ave at bx igh whit Fn wld ‘hw te iow abe pa was Big pale lox -Emuleting Erling ent fo moc epi pening dows os, od ses you auch ‘nore vial cao of he woe of the program. Th lw You Conn a poke sith ar end that nk ike an AVR ship to your compet, The frultr soft thn mates tbe Probe behave xa ike an AVR chip ‘ning vou program Pings poe ina your souk sal ge ou te Sine resu arting al AVR be ret eens ng hat ou a ep Tough te pogtam sow aed see the inne’ workings (ester et) ‘hanging Ins ay ye retin the progr aed he ee ea adhe ‘ey hey wor loeter Unfonante elo sanB ejense = sal ‘Shalator Anes ICE (ln Creut Eman) “yeu dr ve an ema, aer you Fished emslsing or wi ae progam acl AVR hip and atin yout esi cresg Berd One eh great otis of AVR te Flth matey which sa 0 hep Fepopamming th same ep. 50 yo ean te apply propa Your AVR se Itt weeks make some progam susie, nthe program with ie eu inprove coe artese ait to ing methods you obviowly ned soe so feet developmen oar. Ifyou are making YOU eu Yon wil eed acu serain pine on Chip sewed pert, We wil no eaine Kotha done araware gure 22 shows the 200 chip. You wil sendy ve ii wih he PB and On pits: however tte ae ter pt th specie Fnenons VCC i th resupply pina inte eae ofthe 20D chp wd tues 27 aod The atowedvtage ange depends on the ci, ut ls bras #8 5 Vis general sfe- OND the frou (0V) pi, Thre lo aR po “Spe overtetay mens tii ace lv ater words ok te AVE ‘58 jou aed makes pis ow (frat eat S . Tomae we waned ies btn, could ea rangement sir tat fhown in Figre 23 “Te omer apply othe eis kh fo take a or tne vo sable ose tamed om oer eels ead 4 “war tine Eforethey sue regular rin sas tinneceary oak te AVR wat ht “ile er pomer stared on before running te prop, Feu hs a 28 Basic operations wth ATIOSI200 and TINY? lia ay gst ion the AVR Casing about 11 mower, fou hve 8 Parcs bad power supply culti,andwat oxen teen is "iny orig fering Gly you can doo wi a iat such ast S260 ‘Figure 24 lncease he ve ofl aerewe edly Basic operation with ATHOS1200 nd TINYT?_39 Foal i XTALI and XTAL2, a hi names supose witéd 1 # gst (r eens eslce which sping to Pode he AVR sath he ‘dy ple reeds in ero kno eno ave ome es struction. {Ther th ert the fer he AVR wil tough the Popa seuss, thee ae maximom eur for cient medel Ths oun fob iisbetiee ad Me though th 1200 ring ins hue can rn Spee opin 12 Mi! Nota on sme AVR pase Tiny AVR She (200 herbi senor of | MH wih meas You Gon Deeds etl Titers silat op ett Srnge ‘ten and href le acer dre sate oper os ‘ions hones iming scary an ce sanyo fe Up space fon Gece tard and jute the intemal xi Figure 25 sows bow, ou woul wre up a yal or eam altro the 90 XTAL ps. a Te “ee “le | ee tt ee ee sar ain ta nee en ars See Cc leet aor Cee ant eRe AVR Studio - programming Ince tea propammed AVR ou wil aed a cut ton or devel Tutu nisin ome ow od Thm ‘ty na dt uch o cnn 90 own Geveopmes bear © lhe 8 saber Bf the prec cored in tis bok. Te gue eet Sagra forte LEDon propa i sown in Fb 27 ase operations with ATWOSI200 and TINY? 31 you tie sdslemen bua you may need 6 check haw th LEDs wie op, We have bee ange pine wl sore the LED’ erent ( Tame pn Sigh tm om the LED) yor eeu tome conigre soh ‘hah pin is siding the LED cures, jou wl ef ma cages te sofware Inthe ee, 20 wil onan he LED ands! wil tr fhe LED ‘heer inten ef satng with ll of Por se 10 Ow the Sat oF he Pcten, you wil wan rows OAL! Hata Po (otro al the ‘Efe You wil ao hve ocr Por, be other than et in or om ‘ne LED Thiscan te doen the bitin plc of Ale otha sitboeh te propa hasbeen writen wth i120 in ind ty chosing te ines pds! AVE we hye made the rota compa ‘ihal er nodes sarin oy be alien 1 pe Tarte 900 ve an 8515 (uhh comer with some developmer: Ke sel change he device and incade ines a your poston soul werk ie wl sow pros the device ang the STKSOO Stree Xi The ep required wit ie eter pes ef propane shoul ow eo much Fem those Te proga yur device ae he hip nn the pris bckr he wozrmning bear You mary eed change the jn sls ale he eve chin Is AVR Sudo let Tals» STIS, and choos he lea {vies (01201 Yu wile programming the Fe Peta meer I {ue jum Bsr smling snd Yur programe. You etek the De lpced Uae Curent Simalatr/Emuatar Pash emr. od ten Bt Program. te progr sine Sie Emule emery jase the progresses the sim an kl Be Fuse bis ou mayne some ahr bs inthe programming wind: The oe labeled Fises enabler yu to cna se af he wre characteris ofthe AVR. ‘These fae ary tee irene mel or he [200 we have mee svainble,RCEN shoud bes Iyou are wing the neal RC oor as {our lac, Ifyou are wing weer sick chars a indeed we {Sein thpojer he ft hold be clese The aha oe SPIEN. So Progom Bownloodingwtch allows yo adhe pg ack of hp yen nat Heep oi rosea oye nd don thers tb abe ‘ore ff te chip. mate ses fre i i cea ‘Allis jo see ae LED rm ny sem a of alin, Qu ee ‘ac pater bigs come Programs B and C: push button 7 © Tesing ips Consting cups ‘ae i Sa ase pean th ADIOST2OD ont TNT? sit aw examine how oti nd uses cone! n cut Agta ESENATTe que smpie = ps tor a0d ae TED wid as co Soaps sd ue of hen ele There 0 9 ‘Sinwich we a et apt Test parc ia PIN ing esi oct end heme aes ror PN ep gt iastton “push bao wl be conte ween PDO sn 0 ad the LED oF, Rowell ut gram i Pigwe 2% sont pulp esi show he seca gram we eed grab he ‘mer! play for PDD, The tepming fe pop wl look resins © ei he pe baton hus Been pescd. Werhave Teo insets oi ‘apo: sie forepbit: "his tet it na 00 reise tip he fllovieg ine the is et. Sip sis oregbit ‘ets tina UO register and ssh following ine ifthe bite Not at Uke sande tase ro asrctons opr ol on VO reese arween Od (eS). Facts, PND, the eer we wil be esi, Sa a Basic operations with AT90S1200 and TINY? 33 ‘sone of thse registers (number S10) Soe our Fash ton (wich mals [ia PDO high en ie ress, ewe bis Pind, jets the posh button ‘eis istrusion will make tbe AVR slp tenet insretion if PDO eho ‘Terttn ne blow hs ote oly aed ith ato a pres Thre shold hen ar the LED, do we wl ake he AVR po ston abled LED rip LEDolT jumps to he section Iabelley LEDetT ‘Aer this ie isan inseucton which is executed cry when the buon it Drved Thine shoud turer fr the LED oan we xa we the Se Sst at ie [xEOSE 2.1 Write them insets woh nthe LED onthe oop doe Sarge he uo ai ‘his eaves us with he eto abd LEE, 22 Write my iastction whieh om he LED of nthe op Sacko Sart, “You tans fished weting te program. nd can doable check you ve ering core by Hoking at Fog & or Appenic J Yous then 20 ‘trough te tps given or tesing ao propanenig Prose A. Whie you se Aeing your simaaten, you ean Eiultethe btn big pes by Spy ‘esa he box fr PIND, bit On he VO reper Won ‘Sometime lps 0 ep tack fom fe bi ad ak a i fre ih sted of ohn ah uty apd LED a prt isn he pot lesiao them tn eget obo they ale ene mart ae prs. ‘Whenthe ph bun resid the marin la ODO000008 te his ‘ase we wont he LED tou (make amr Por abaGp aU) ‘When the put boron fant pres Pi i DDOOUOUOY god tru we wa ot ob Ob0000001 So stead of esing using the inal Di we ae ‘ag 1 seth ere maber Bld in the le rept. The ene proses ‘Realy ole moving te aera nD mo Fort, Ts arse See ren nd vo we wi ft ve orend the ube of PD wage ‘owing nsaacon: E le rgiteniony Thi copes be number om an UO reper ino a working reps. To move Bese operation with ATIOSI200 and TIN? the nub fom working reir ack ut 138 HO rep, teat SSE fete propo hele const of i emp PD reds an Sa out PortB, temp } controls LED ‘imp Sr ope ba ‘This shor regis shown a Program C Seven segment splays and indirect adoressing ing n AVR coco seen samen ply ean ong» seperate Weis go Sgn ave” yor wats bem Oba fhe mma canbe pied bt also met eres: Ase. Co Ey FG TERT Dna OenscuUymdz “ihe ls of be even scene’ apny shou al be come ote same por yer (say ak PCR og ei The are mi eed [eine dt on he capi. Mae note of whch bomen (be ec) a ‘Senne wh bse segments oa senses psy we abled | ewes sample 2) Fon B Be 7 = 4 BLS =, Bi Se, BiL4 =p BLS =b, BIL? and Bit |e The assignee ees ois na random order i Basic operations wth AT20S1200 and TINYID 35 rare euget than ober The sofware ie eay 1 cange ~ the Radar ete play swine up at cee in Example 21, th amber to be moved Jno Po whan sreting ita be daplaed sul be nthe frm cg (Gdoer® mane ar bir it kart conned fo be isp where {tio ovate wh each ter cresponae te ogied seo ein oie hat pric seamen. ‘Sy re ng» common ete dpe (Le make th segments high fen tom to tum on = a8 Fgwe 310) nd you to delay ream ‘Heleter A. you wed wen on segment 9-6 COMMON CATHODE COMMON ANODE ra rs oe Ty i] ch ott on oh ‘commons ef : cn . | oe oh i] pure 210 Given the siunioe in Example 2.1, where the segments ave arnge slong Pox 8 the number to be moved into Porto delay a8 ‘ald be Ob0{111110 Bi as teen made Gar ise connected 0 Be in, 2 Example 22 If sme of» commen tod dipsy ae arent Gaegble- slong Por, wha aber shold be ore it Porth oS Jeter Cand ele? sg sng 36 Basie operon wih ATSI200 an TTT? “Te eter C requires semen 49 fs the number moved no Fort B would be OIODULI0. The eur Eregutes pment a. ead soe ume to be mond iat fy B would 04,0100. vancse 23. f the sees are aranged abet long Fort 8, what, uber held be moved ort oy he munis O, 123, 4 5,6 WES AB dE snd E “The proces of comeing a umber io asin apes cade cr be cai Guin vas way ut rte spl nae ings loka fol Tae 5 erring lookop ble ie ares adring So ar we have bean (aling wih cert eddenng. jen oe aber fom see umber, singly read egiernarber Indirect abdesig nce (eadng# number om reper umber X. wher Xe pen ins tet (eet ead 2 he 2. vpn spread oe ROO and RS). Wee Iie sedig Teer wee eI he ements OF a waking eps ROS ante see Ser para Z Example 23 Move the mb Dnt wocking piso murs RO 1 R29, ater hn wring cr RO eas 9 Sekt Sars RI oR tears oy tears RO ie can ue indirect aresing o complete he eb in ewer ines. Te Fs ‘Hers we want owe tu Rages O20 e hold move OD to {raking Ob sare on te eter) emenbe ir epead ove oth Zs i ie hie and owe yes 2). owe ned ter thm bo ek oH seas 2 ieare 2H ‘We then ned et up iter with th amber we can seit "yp tothe cher eigee We andy havea reser ih 0(ZH), 0 9 Wl we serie “hsndiety oes nt) he ae in et thers pointed fo by Z Tametre easton Ce 3 Spe OST TR 9 8 mE : sends the manera ZI (0 1 the aes given by 2 aso Oh ands ee ‘heels RO. We now want ear Rl, an s0 empl loees 2 Dn toads (Le Rt) The program ten lop acho eke oup She reper clearing hem all ina ows lines a iP wee sn Set desing All we cdo dois esr whe 2 reaches 30 ps) ‘henge aden we wth lee or dowel wher ZL reaches 0? We bret 30 fam tad se wheter ox oc tees 2. IFZL 30 hen when we bar 30 fam be fest wil be We dt nat ocala 30m Hr wl St Sg ackvards fs! nad we se oof the opr con © pion ripiter ‘This ‘compares’ she umber in one rege with that inant (tly subatomic fm he rw eaving bth unchanged ce Deets ie eat ao We em oth ty aang tc sie These te snub of gs hl inthe SRE reper S3F thee a soe ‘tnd cleared depending on he rei of cern opens Thee oe fer won he sah af repro ee Thee wp on “This niches 1 anaterpa ofthe program if bin SREG se the 220 Magis andso it weld ve fo bea) Noe the Ro! hob thn (3 asco rin! naan. Sim ‘This branches to anor pa ofthe program ia bitin SREG iss Here ‘where some ofthe iaructonredandeny comet best wel ts {eel siaon reg 4 SAE ch a son potter ‘ecb Inti ca for te 0 a which ands fr branch feu ere sell, bach if te 2 fa is The opposite ofthe > bre “hbet : hich ads fer ranch faa equal re specifiy, ranch if the eo fag 608 ati | 38. Bosc opraton with 41905120 and TY? i ot Tecmo a of tnt il tn hw ‘Agenda Cong ith thr eras suo To compte Te ‘Wi truer endear egieh wwe Oe eaurton cok eogiter umber Le ve ae tt hin wr oni EB ha 2 ‘hg The comps sof soca a epee OS ee ie ow setae 2 ai Stan 2i cart: Hz SR tet ol ‘Compares 2. mit. oe {mcs Clare £2230 eee iemtneama chen Er EXOROSE 24 Challenge! What anew Write O10 RO. 9 9 RL8 210 Fo eal ie wayt0915 RIS? As wll swing indy we ca ale ed its Berit. ‘ ‘Tain ds ny eter te ae he espe ob Z. We ate aah of rami ke a of ene een sine ning eo ao leat eS. fr eae SS 8 i fr se eg die 09 weg a TSR he en oo nn 2c Fo bo fe ‘Shean hn the munber we with eamer eZ Reading temp gt the Seen see! defor tha amber a2 saz ton $e gto 2. i oe ae Rene op fot rtvtenp Fouts mp oF tastes he amber into seven sept code wh eR = ES RM Basic Speration With 478051200 ond TINY 39 i he up though Port B. Noe tat you wil ave 0 wie he cove wo ‘herepser inte fe place 1a RaQ, 0b11111100 cade or 0 vai Ra1sab01100000 code for Jai was. abiEIONIO code ord Dts Hat atng wong egies fo hs panos ena nd indeed asf but te no ther SRAM oo te 1200 we Bae eee the cis that do tive SRAM. We ur tht foe Lae se Fanteror. on ah tp te ia an nacion pm, Mick thot ty 19 ste Program Memary for leolcp ales 85 well Nite ae mes ae ese Gate Sister proet on pape 6 Programs D and E: counter 2 Tesi ise 1 Soten semen cts (Se oj wl be» cour wl coun te munber fins ph baron esi rm Ot 8 afer 10 aun (when pac a copa ‘ude Te soem amen dpa ills o oe Pon os sud pth bon wl bo POO ce 211 hos arate ariel ete to How te our io ht fen segoen ae ‘ranged The Sona i thon i Pee oe wie he nt tien ecsl reringheplip on ‘ston Sar Port wit the cue orn one dy Wie wi ees ‘eggs ced Counter to herp rack of fe Cum ou heal ete the deteraons econ as RIT stn en aap ee a 2360 may emer, eg, RI-RSI re he cee anes ae ‘everflepsrseapbl of wie age of pean: Whee one, fil prises fom RIG upwas and ten ae ROIS ae Ink sso, presen R20 w RE wo bld esse epee ne imben Oto. HINT: you do ths tere ng p Fort erase 0 eager w nie Ay rem tacos Coan ne lncsesae) xn 25 What bert ltt te path btn op backs eit sz ifs pee? I pressed HS jap eof he a esa eto Canter? ‘Tega ocd ec wheter Conte n cele9. We se compa dn tsp ity went ep Counter mt bese api | | {2B pein with ATBOS1200 and THI? “The program 0 far i showo as ProgtamD. tis ecommendd tht yu 3 2 Bo is prjet Try et ana on wl spat te jr Rw nse proj "Yn base problem tht we ur wang fr heb ro be Pelee ‘ie mass ht Counter bring incremented forthe nie dation of he honing eed. Ie imal ha he bust i bld Cow for. ard ‘he eral fluency Is # ME ove tip aoe the prow rakes abot 18 ‘hock jes, and go Counter i ncemened aboot 4 00 oG0( 4 10)= 38 eo tes far every ress ofthe Bun! Enel what We have 3 pe ved random nunter fevers (e aside, andom mune enero ae {Ge hard oake witht sme form of human nut carters eo Jood {tein and You ood mike his i an arwone de peje bu We ‘Siete tocar nga sim of rea courte, igure. shows the now Rowcha. The acesay ames can be mode ate ent athe baton ob lege bore lope Uk fo sa exencst 28 Wiehe no ew tnes need ose the problem, ad sh ‘Shere they ato added (HINT: you il peat ves lop ame “routs ew peta Program) dy ay ste nsrng ble temp, Mara40 compares temp with Mark40 Bene Sar Hit equal oop ack to Start subl Mara, 240, jas 240 Markaaa ec Counter subsets oe thom Cevster feme Surt 1 Hfmoc aro loops bk ta Sart This should be fat fom he a eto on ining. Noe tat ina eoping tek to Timer tops bad eStart You may fing howeve ht 8 an reduce bron bones by looping back to Timer rte thon Start the (01 stead loop. This meus the Byte wl any be weed one every Ot ‘Stood hich mean fst bun wil ve fo be peed fra Tee ‘econ After the ol tine hs pasta we nee to hase te LEDs (ere ese eth Coane gine apd Todd mov retired? os “This tre (ope) the number fo eit [BEAGS211 | What on ine ress Counter wth ie vale in Speed? Basic operations wih AT¥0S120 and TINYI2_ 1 ‘Toros pater of LEDs we haves number of rtsng nstoons tour pos {sites hin igh ier a Hopes! shit gh wa opi sitet Por {rota rigt ri rote et erie 8 hes hing heb oe i hin espng bt same an puis BO th core. Tec Dag nt {agin SREG tk te ao ap Te lg sh igh he ae i he ‘a and moves On bi The rote ih rues tough cas Map oe 117 lade ith te a ag and nde he ao) Ts issuneaeed in Fire 217. a “st Cua « Ea Pewreaan 2 ere te ps slong We on’ wan ay I pening te ends, ‘cae is would nee LEDs ou of tn woh youl ea popenay ih rou nr rw an en Uo ‘propre Forth sale of tpt, we wl pc te panes Been i cast apy hse rutng noone Gey Foe So ae ‘etc te pater emp oa tmp, den opt es Por elas we gut ttf, we vets seer sea eS mae ‘Base operations wk ATHOSI200 ond TINT? ota ih ies) nish cae we alt eset Port act iit ‘ale ato exept PHO). ean So as by manos he cary ag, wich Wl be high i we ont iho teed (n ue glance at Figure 2.17 ‘ould oa hi) The insrten fer: ree label “This branche to label the cary ile. Therefore the line we ned ae: fe temp. Pot reas in carrent state fi temp rotate tothe et bee POD hers Car sip if ear Tek emp 0600000001; Fests to PD on others off ‘ie Port temp Stare outpus to Fort Ps bak Stat ‘ou wl nie that if the sary Hp ile. We hp he ex istration ving ‘he PC¥2 nk Toe progam thon rs nia Progea Fo Apne 3 ‘You can goth ad aisemble hs aed simul For the snlation ou wll oe tha sepoig troop te ei rogram wating ae Timer 01> unt up wil ke on te Far ses ys orn took pr of he progam 3 high sped se on fe. For example four ch ons no {he prop (shen in smlsion mode jou ae ge te eon t “Ran 2 Case (Cte! Fie) Thi unto sere you hve Sched gh peed st «gute realtime bat are) ‘So fare have covered git fw narcon: is impartnt to keep yack of al oth, 300 het st your fingerpe. Even yu can ene the eae asturton maou ee Tok ee up Append C) you ssid ‘be familiar ith what stig ae sulle. evsiok EXRCISE_ What ote flowing de: sei seb emp. hs. 1a, eh ein utp. pis br, bbe, re. re Bee sul des In, oN, ‘sell or ani? (Aas inappenn O) Timing without a timer? Somes we wil want tue he TENT foe prone (ha counig Sigua ca TOPDS) and ove wil om cok wring wit ewe oft | ‘Se: Each nection aera speclic cant in,c0trough ewe eae {ily ensued Tops we an net ys whch se jut a acu 2 wi “Tier. The only de of ss ate gp canbe ered (3 ‘bron i pes) ie oe Tier, wich Wi keep counting rele. << a Base operations with ATVSI200 and TINYD $3 The el is 0 he mane of eck ew ead wae sd oust dwn fan his ave. The robles teste seb ces tte 2! (te ce sn lynne tne es sochow lt he mb ore monde ar aa ae ees See ‘Wedecremeat elves beet goes ono oF Gone hoeeee ne 1 ot) and hen erent th no ihe ec EEE Brant 27 Hike se Lert Cary tg? fate tia ot fia oat oak outa OA FF YES (a ceemens apes) Cae Sie os my ae ‘The Fi sep i to work out bow many insrucion eee the time delay equ For example to wat on second wih 2 4 Mie esi we age “kl 4 milion cok yes Te lop we will wri il eke nas ele whee gene Te 2. ‘ate z ‘Length of ie wih MR lock With 24576 Me dk 3 08 a ota ‘ Sarton 102 ps ms 16 mot setae 26-6 sends é 403 seed 17 mines 7 ecw? mines i enue 74 tous Pi mines 120 hos ‘fap, Fr explo aes ae Ox, O05 nd noe ‘Atte ef he ly he rg we ps teas ae no fe eg tecrnoe e e m . 2 i Dap, ox00 i Damposs | tdi Dawpaorec ere ‘_Base pean with AT51200 and THVT? “The da ise onsite of joo ine pr dy reper pone a he end (ie incur enz our ies), Tobey us acieve sch Short oop We need ae se regsnumber ‘Subrat thnedite nmr fom rept, and ao mac | ft ary Fags se For example fs Datg2.0 “Tis eve sera | rom Delay 2s te cry a itt and bic 0 shri, Or dy oops as flows Leops sublet, 1s suberaes 1 from Dea ‘bet Dein2|0- subent I from Dely2 1 Carry set fel Deln8,0. jrabract from ely If Carr set bree Loop "lope back if Carry is lear When i fal skips otf the op, oe second wil av posted. Te is ing wo ate tthe eng f the loop i five lok evel (he behing Inecton her mo lack ls) Youcan ow ee hr the mera Tl 2 come am fr every ext dly eit yo add hr an enact ‘heloop. Te rason we hae wed subi sbrat |i of de th nike Sb de doesn et the ary og, ele ely ot cry inert to kow weno sboc fom tefgher byte and when fo skip ot of th sep ‘The program counter and subroutines ‘There isa ist conte, alld the program coun, which ls he AVR hat reso eente ext For ora ineuctrs. he program cost: (Ge PC fest) i spl increment opt ote ns inion in he ‘roar Foantimp orbrne ype insrsion henner inte PCs changeé 5 tat th AVR wil pe ste ee athe program Example 258 sua shh PortB0srurnson LED (3k Sle Pind, Fut parh button Bh Pord0 tun off LED Base operon wih AT90SI200 and TINDI2_ 5 Loop: ic” ae Counter SD beg PCH 5 sie net ie 0 SE imp Start : OF Hime Laop i Te shove example segment hse propa memory des fr ech Inari on ied wi satin Hea ke eo fen seas nor eel fre sol belng he drs tt fetows: tok ote ttariur ft PC in sb stra ane Spon colton the i nuron germs 3 Then Pier? iStese ifn is hgh the PC ply eemetdO8, ba Progam sin t-te Rae creme ct OC. The ap Sart Seurcion moves (9 oh Pang te rom sip Str Ts tse same lip onthe RED uk ev tals ow ies ay ‘es inot eu (ces fag cate pogam ade 0 Be PCat than ots sipping one ition ExtHE 212 In he cumple above, what i the eet of the insrion Hip Laop on te PC ° ‘This om ings uote tp of sbrowines A sbromin 8st of ‘nsrotons whe pg wes Ju an sce fam aya nthe Drona: When the rons ede prog stron nd arson SRECTE leh oft te hey fnure Rew eet tate chips to ‘ononber where was ten sade bowie So tt ean know ‘ieee cry on on hen rts om he arone Tis emery prin wha tno as ek tou can hk ofthe suck ssc af Pope when the brute calcd he mane ne pogran cone, paced oop ofthe sack Whens tuning aac read top ‘umes onthe sac pct bk the popam cums us be VR ‘um ice intone bul he rove Te {boOtas tree ee nok When ssubouin aed wine urotne the numb inthe Pe pled oo f the sack ung the pens "uber tte level bo Te mibecpon rag etecton wi as vay let he nmr on op ofthe wk adi ite PL te evel sack mane you canal ebvoine wii sang wie 2 brine, bt tts sbrouine wins morn win ubotne ‘itn eben Thom one Jove ped tes vl oto Ubesck any cl ater abst, Svc pag ante so {be sak te btm ofthe sack lt prmanat The samp Fy ie ose th oben ~ 36 Bat operation with A020 and TT? Basic operations wih ATOOSI200 an THNYI2_ $1 mot ast m : on ten SS Orsi my oie wit ene oe = = ‘Subl: reall Sub . a! fm ml SG | eee B32) | sae eat swt ; | oa aioe 1 Ee st ie porns ofr fv en wpa om his es hey ‘ould work om mare advanced ner of AVR). Thi cess 1 be se oe Sthaubouines, and ifyeu ae cbeloping ese propane on 2 chip orn | {26 1200 rn AVR you wl ave 8 ewan ot nt nse Ini ‘tan = Chap 3 explain hy i temp, LOWRAMEND) tach poter pins 0 Speen PN RAM wed temp. HTGHGRANTEND) \ The simular baton Tiss 0 tep ona subrosing—.ran r99 ) the sroutne at igh ped and en moves on fo he st lhe ut bane. (used when te slate poe in in uine sd l male ‘be imtinareun ul he eum nara rene Program G: counter . 3.0 1 Detoucie ips 1 Seven spent ply Now ta we koow bow implement sine we cap ok ak a roving tte coor projet to cde deboncingSeareso eet te tof ‘non tous The new fovea ie shoo in igure 219. We can se fom Ge flowchart that eee oa oie delys tefore abd afer he ReesseWat soa inte progr’ Rather th de ‘ting to delays, we am hive delay subroutine sat we el ice Foe ea label : ‘ample fe cal ou do surotne about, bvng wed ba [stow ae o be aw pope hihi ela at an the subse neds oe witha 208 isu ‘sue al een Toren fom a sue ue 8 Barc pein wih ATS0S1200 ond TINY? (gene Bee ee asc operations with ATSI200 ont TYLA $8 reall Debounee Inserts required él ReleseWaissbit Pindye.” baton releated? imp ReleaseWale 0,50 hep oping Fal Dobouae | Hnsertreqied deny imp Stet {ass in eops ack sare ‘Bnaly we can wrth Dabouse subroutine ke aep my sbouties ie {be tp al foe yge than tng ay, afer ep Ie bat ‘efor te coon es Ins ease wl oe he ely with Toe ‘vERes¢ 213 How may clock eels wl ate crete 0. Sead ea ve 34M rel Converts uber et hexanal a8 gpl I Up ‘vers rer of bes, Wal shoul he nal ales ofthe ey eter be? NERS 2.14 Clone! Wit the eights tnt make pth Debounce ‘oro, ‘You must lo remender to define he tener Yu Bae ad With OO-RDD taken up bythe seven sepent code reps, 4 R303] belonging {9 ZL and ZH you ay hk youve ron out of weil ord may hae © he theless yrie RO-RIS. However ooce tu wie in he Debounce $brotine you a9 ng the ep re.You could href we tem ‘nna of Deas Ete define Delay a RG (heres ating tty wong th hig ese to deen ras) oa ss pte conus You ny prefer 10 Soup ibe name Deny] a we temp ined ine Debouncesabroutne Try th popram tad ce f you're ented he ‘fe of the baton bounce Cn you ake th ne delay sale? What oe ‘minum ine dy hed for aie perorman®? Program H: traffic tghts 1 Tinieewitou TinerO 1 roaging opis ur nex project wil be awl ips coo The i es of wai 1 formosa ser ene) ss tf he oped a gros witha elon WAT iu wel Thee wl lab ae or pote ‘nso press when they wih nose rod Thr wl be oi Ser Uns ees forthe tail We wl be mening thee aren Don ppestesas thr lta minima ie loved betwen gach meth alec [sapped (aie tse the pateaiancosingh Ar walt a, i seeder the eg of eth iis yom ad aking We wl we be “Time 0 contre ema tne betwen futon pss (wich Wel 0 2 tcods) and we he Tae tod jt node foal ot ming The ce aga shows gue 220 and Mowe in Fg 221 ss Sar 12 Basie aperations with AT#0S/200 ond TINY “ou an we the In sction youself ong tht PDO ees intra pul, Setup TENT to coun a CK/IG2E “The ist ne 8 the LEDE in th cost ate with ter peeing ligton ar neh arte ears’ gem, [Banc 215 Won wo ines wil ois? ‘Wezel op 9 a we iin ng ef ase ng et ec 5 ean “Thr weil ahen care by t bowtne aed Ter he wl erie Bes Sonex ofa ins er reall Timer In iis ebrotine we will ste T bit in SREG, 2 tanporry i v0 ea se fae yout ove purposes. We wil ue 10 sal tw be tet he progr Irish ar oo ergs 25 onde hve passed tl aa 9. Dt {Fert stopped andthe people conse aires. When ea a9 ‘mer real th coum dwn rer tl suing in op wl the sas pasted re (sing re fe reed tine Ban uted. Wick ‘Fe reqie time Goce pas the bits slered na andthe ret of he [rogram Kae ts OR eso he afi opin ARE: hi iran We fs XERGHE2.16 What olny wil he ex he pth belon nd op Bak to | Sarit eet | ‘eros 217_1fte bas i press te pees’ WAIT lt shoul be Tuned a, what nei ue as? Totes the i, you cas eon fie following insti: [ ‘ea abe *branhe ifthe Fe rebel branche fhe Tt Sar XERCSE 218 Wat roles frm 8a loop whi cls Te, sad ests The T bit io SREG, singin te oop ut he Pt Sse Alter the regu tine as pss we an sar sowing te wae down Tae She green mous lght Of, aod he aber ox on. Keep al cher figs ‘acbanget renee 19 What ote hin his? Aste flowchart sows, he ae gute 2 fo tine days require ad er Bane operons with ASHS1200 and TING than copy the same ting oer and ae, makes see to wea tine doy ‘lvoe. If we lak a he mim lay we wl be ming (ic OS von for the ashing we ean ere # 6a Fis length an nut cal seven tines cet longer as The delay wil be alee Hales nds wa 4 sends we el youve ines. We ea simpy we ‘all HallSeeond eight mes, bt sher Way would be he flowin Wi ems Fouseconds reall Hausecond fee temp Ao Bene FourSeconds | ‘emp is loaded wit, od then each ine tis decremented, HalfSeeoad is ‘Sle Afr ing ab mes ap oa oft loop, “ite hissed ely he ed moor’ ght mut med 0, ah he aunt ase ff The red peesiian ip ust bene of a8 he een St Gn The pedeons WAIT ight mat sho be aed [=2036 220, leh ne ne wil ak the ou up canse? Which our ines key an 8 sesond él? Afr se # scons the ed motors gh uns of athe atari smber fd plein roe ips ms ash Sty tring he ang ligh on ed then ne Wil ok at ow to make fe ss. xenost 222 Which me ines make te requed ouput changes? “Toroggle the eqs ro igh, we aed invert th ssf he is. There sretwo ways to en be. We col ake he one complemen of eg ing com regiter ‘Thisaver te se ofl ofthe isin ep (O base 1 become 0. vencse 223 0 be number in tempi OO1NIO011, what reuking ‘ale ier om temp? However, we want reltnyinert eit. Tse dne wing eee (lege command ogi command lk t ne or mare bs (a pt) {depending on ei sae prodare 20 oat bit (oe ceil of he foe perso), The be showing the eft ofthe mee oramonlnctive OF eneaod a2 bis now a # rath bi) eh blow fore a Base operons with 41905120 and TINTIZ oon “Te uta bit (rsa i igh eke theft o te ec0d ipa iis igh {oritoemaretieh) The enceve OR i ifeee na Boh inpas bith, the opti (Ope afte wef fect ef scan bi the Fis bite and STs eemod is eft tage ee er sous nb ae tow erin bran be sles tgp I wou aed ogee te fergie we wad exchsie OR te Me fpr with he rane ‘donor "Te exclusive OR insti cor rg This extsve ORS te amr n reg wit he umber eh leaving relia reg xencat 224 What fw line wil read sat of eights io temp. see fry toggle bi and nd thn ou! temp Ek Part Hse You wl | sedesteeecaie) sence 225 Chalnge! Isao te previous seve ino a lop shat twas Basen, slsively gps fhe Coect ph, and repeat ines You weed neu pier ocsiat the umer es rou the oe tal ds Counter, adel he lop PissLn. Tis oul ake eg nes “oe tli ish can nw eno ei rin sts ba before opi 12 Start remember to seth bi, You can os iy singh lowing we saesibe Tit asc operations wi 79051200 ond TINT? 63 cence 225 Whit he ial fhe prog Wt emis fr us nose the vo ebretins, HalfSerond an Thee We ile Halen fir st oul be the mere Seaford xsnese227 Witt using the Tint cet half seo dy, an we the io write the igh Ine of th HatfSecendsubrosine. A 24576 Mie yl is eng se For Tune, we fit et the Ti Is cea we a8 simply re. xERCSE 226. Wite te froin fhe Timer strate ‘We an thn ase the same method we weed lore ing nae: however, ‘nread of looping fe lop af the ection. ret om the seating The reed ine 25 seconde which op 24576 erst wh Tina 0 ‘ming a CHVIGR4 earespends toa mae of 20 and cour of 250 (Wook sere 2.29 Cialege! Wie he rein eines of he The sudo tine same your cour and marr reper ave Bee se up nthe Init ‘Sin (ti) ad ee the cou register wth il ae he end fhe subrouine Dow feet claret the end ote sbratine (ne thet neta Congralaion! Ya ave exenly writen his whole program youselt. To ‘heat the entre progam lok Papa H Append) Logie gates ‘Wed shor lok the inclusive OR ad excuse OR age et, nd now wel fal aoe pes: AND, NAND, NOR, ENOR, BUFFER, NOT. The ‘uh be re llw fon Pa eee Le | (lapse nie t - frets jcre | = a eee erate varie Re = ar (66 Basie operation with 7905120 apd TNY2 | roerefre ANDing 2 eps with ODD0111E mass bis 4-7 of me ete, End ewesVis0-3 he sae, a] ie opps of AND | ris he oppo of en OF ax operation with ATWOSI20 and TINE? 6 ‘Theres specific ncn fr all hese gts, ba hey en be ipl sree sng combina ele insrctons Program I logle gato simulator «© totie fnctos 2 tiyave ‘nes projet wile 2 lope gmte imate wich an Ye propane | Seas any af te eight pts gen sbve I wil eer Pequot ‘hoo auput andthe apts il operat wai gfe to emule “This makes tl fx UO pis we jst Fonte iy AVR chi We SMU be sng thie rogram fer the Teny2 AVR in pare, Bt an be oped reo eater yes nln the 200 ht haves far ees “ting foc Figs 272 shows he pn nyu of soe fe members of te fk. of ‘Base eres abou is alice ving bit Port B (PBO-PBS), bat ‘hese six UO pias re aul ol under enn ceumsances For expe you canst PS ni PDA ese hci nts and ue ese 10 pins requses mecion of the inera ei" Using 3 separate ol Ir (nd err cy wena XTALT a alas opt) means PA wal she, bu FBS fn Using the RESET pin a ramon means esis PBS. So os se a havik VO is very much mtimin Also, ke nt at {ote Tiny and Tiay1 PBS ian npr on On the Tiny, POS an pt of an cup drain (5s ears Yu can make an OUD nl low up oe can nk br tt source caren) Tie meats Gat sough Pia xd DDR are is oe. Port is nly bs eng PBS therefore a 0 tral Pulp andseacodron eterna erin As aeanage ofthe Finy AVR et the 1200 mde ne ve ben sings ar te alt of te fllowng wee Basic operations wih ATIO1200 and TINE ‘This ods contents of he prcram menor pied by Z nt iter OTs nen we ean se poem manery fel a ook up Ue, es ppt tang ap wering eps hao ate cent coach {Merocon ine pose money 16 is lng, we oor 2 es so pce of te imrucon We wl be mening ie intructg ine eae re hh oe “The sa gram fr he ite pj shown in Figure 228. Noe 2 atthe NOT mn Bue guest ony oe apse owe bess PB the input for tee ues Three the eetve pa th Des fer The NOT snd Butler psa asic paaions with ATNST200 end TINY? All i Beg t! i xenose 250. Have a go yore at cenamctag the Nowe, before Teotice wm» eon in he swe etn, You nel tt make ae tas thee Bae earn ren ge ensemed with arg oa ot ange Ue ining fhe dsl pe es ‘When sting It ection te ort PD, sold inl be OT choose sic oie th AVR rt at ives ir pe whch See tuys eee (00) nd (111 depending on este fhe sith We ee fee eo as i heprogram to deter which ion foun Inthouh heap fom the sh Between OD sad TIL the Msuting rer Pins Baers sO ad de wee hes fb Bs End Smce gordWethreloeae te mura Pin a ash be one wig andi reg number “hit ANDe the smb egies with immedi mame (oh rep vers R683 To mack bits 0.4 ap 5, but ep Bs 13 intact we AND oe ‘register wih C0010. We he ose # once oe ah ng se ha ‘nly ters ape in 3 dring he son, xeRse 2.31 What ihe appropri rtininsrueton ose? “Te resus mune een Uo Tick esl se ase estion Inthe protiu mamory and we ules Hn nto eZ esse asthe Mle ued a pote spect aes, exes 272 Wate he hn ines which ad Pi it Zk iO, 590 te ote to te bn ae ogi: ‘lok he wil begin er he inp Int This ove ‘oa isa ads 00 ee progr memory (Wis why i te Ft oe ez) Inseutions ae 16 bis Tog 5 ake op 2 es (oo Wor. ‘ropa memory aes thee word arses, she te ade {sums te word ales Fgue 226 Horan i BOR: 5 i | : 10a peation with AT9OS1200 and TY? word 00 (010 0011 0001 0000, = and 16,17 byeug © bye! ‘Our lookup able wil fre tart at werd ares OD tc is equa cee ares O82 ZL pins tebe ates. we wl have to 36820 ‘EL za poting toe bono oe oko ate xenest 2.33 Which vo lies wil add 210 ZL an hen ust to end 2 “ke om be pote memory ao RO? “ow th en gution i wha hae ine ok le hat i ng 0 Ye pram how tat Uke paral loi te Aer some though Thane eestor wing i form fhe he far each te pes he mos ‘Sigurd sen, What we esos 1 4 pon may ape fr fom ‘het aptly afer some ecg goo wile rutin Ss heres. "ice ging to havea byte fo ach cyte For each gate, we take the ru and oa te of ouput ees (0001 or an AND ote and SH fran indsie OR). We ten pl hese ies io to et of 2B. tnd steht in # and dO and 1 ofa or example, AND: 001 mo 0 sn OL and he ezames OID nce OR: O11 sets "oO ad ean te becomes 00000. sex0st 2.4 What are he lot ye forthe NAND, NOR, ENOR, EOR. NOT and Berens? then ithe te lookup abl in any rer we chose (sting it ei atl inte le dfines ow he code a PB, 2a erway ‘Sey Te eer bes ces (aeutins er thee whe li ‘Space te along word be te progr temory. These Gees I (dete wed) and (fie ye) If wine you wil Lave 6 ouptie ys ee above it pas star iy Wsy e sw btNo0009100010011 code or AND and TOR. R asc opratont with ATIOSI200 and TTI? 71 8 opo0oHeNe, vpoora018 ade or AND, code fr TOR. “Tors one impart tees berwee evo ie shove When ving Ihe Tower eo te word haste lover bye aes. Fa example the wo le abo wee bth writen tor ass 0, te ad for oe 1OR woud ea be adiess OD in tbe dw emp abla ye dees OY ine ab ea Ae gm You tke ee of ect De Sea en execs 235 Complete oer trees ofthe skp ble wing de ‘Thee sing them isteuton we lave obnined fom af he eth ble foreath gta RO, We il hen tex np ofthe ate (BA) Hi ow ‘rep bebe RO (eg 000000 Bees 00100), Wh ts dss flee whch af ofthe ble we wish o scene we pp Jo 1 hes The sep istuon sup re : sdswaps per and louis of epser We he et np Bote ete {Past 1s i we re the amber RO to tei, Wat ths es 22h! whch of he outs rm in he th bee ih one. Te fours we eed ieee sis Ping tents tnpuca sep RO saps ables iow Ss Pings Fest lapur ne RO rae ih iy “he ste OF RO, Bt Oso hl te ouput we wih proc in 990 However dork ao cane sf epi the pe ne ‘wortomresnanber to fen drial Ife PB} 364 PO caw ‘a Ruse AN Ding i yt fre eran i ow mang ce Si ORng 2 nay to foe eran is hiph, For example in vee ie TOR RO wih 1110 we il ger aumber ata ert P80 woe ‘tac, Wecan thn mort et fs i or fete Se hte plas wl main The nse OR ison 2 ert repmamber 5 ‘This insive ORS register wih he nunsite number, ut aly wrk on pines RIGRSL We tefore have to move RO ino temp wig Be mw a a a ae "2 Basic operon with 9051200 and TINY? sxcge 236 What frie ke the mbar in RO, move dp. ce “is high ad tes cup Port etre loping back Stare This Fines of be rogram, it sown in complete form in pen. SREG ~ the status register ‘eta en eof the its of SREG (aro fag cary fag aT Wit, we ‘Filoow lek ate rmuing five he can al be daly estes ot "band brbe wich weave ses? ‘compar ad we opie ame her” It yu coun though the a High Speed lop of seven nseton, you wil see it takes eight clock cycles sf TICD doean'’ overow (remember ‘wanching nsrtion kes twe clock eye), What e aed to do now it onc sil lp tt wl erent the higher bytes fis oo high, decrement ue coutig regis, ship oxt if hyve reached zero, an lop ‘ack to HighSped all in he same umber of lack eles. This final pate cial to ens the timing is perfect. Foramately we can o a, with 2 lock ee toma Weiheebe vente iaeey ne an eee 82a operations wit AT90S1200 an TINY? umber af counts wea allowing ote pat it 63999 i the 4 mse ite js too high, Sod so 6¢ O00 jut oo Bish ~ 6 000 rants 3 (xFAGD, wih ean awe can imply tes if the upper be has achat (OKA). rit iat we know ooo ipo 9 elo oh reg skis out of oop ito high she 4 decrements counting eters se 3 bree {ships ou of oop if done counting on rates one cyte ip Bighpeed Hoops back [Now you may be thinking "hang other at nie eyes in he above seme fot eight ou are righ ofcourse bu abut he namber of eles he reir secon if the prgram does nt loopback to Highspeed. IC te Program does nor loop bac. does not branch. and so akes on es hock ele. ake up fori ne leslock jl inthe lop above wih ne mar {his lop. Ths inte foning of his Whole sation he cumin ents Will her dawement once every sight lok yeas orice sey Te lock ‘yess You my ant 1 We the wale oop down a wor trough 10 omonee Sout of eto tate kro the deny resets dere’ ‘vey et cack cyl We pan wok out wt pie emf inode a (reste a 6 delay [NERO 2.47 What should Delay snd ely? be iin’ to “Tats the hates prt doe! We now need immediately sor he euent ‘ale oF T/C The ony problem what TCO has overflowed erent Tas tet or evening and so? We ned 1 us the sae et 35 before ‘excise 2.55 Write the sr line which make up he section called Donel Sieh sore TCD ino lowerbe, and compare hie vow p(k repress theo abe af CD) towed same o Hahe ps to Seton called Divides, its nrerentsupperbyte, es 0 ee iF has Tesshed OXF, and jumps Tonights. “Tee next ston nnd to divide they menber pit op oe ery a uppertyte by 64= 2, We do this by rting the whole uber i ies 12 reat tue yen the leone, ne he oper ye HEM with 28 | Fig 7, an hen ate ener bye bt with ne cary ag ig 7 xenese 239 What lines divide he te number by 2? Base eperationswthAPWS1200 and FINED 83 ‘The Die loop does this times Fs we twp temp wi ce mame 6 then vie by 28 we've das above. Then decreret temp, oon back f does no equal zr. We dont want 2 temp wth 630 weal wat jump t Divides and then pone nstasion. Tis canbe done tng te folowing tik imp Divide6t01 jumps to Divi and then skips one This works with any jumpingronochng insructon and for any numberof skips Now tat age ps eg, #8) lend a anwily peograme wich ae hard {ofall and easy grag 2 [vERes 240 What ve ln make up the Divided section? Diets se if embers to Jom The 2-ye word os he equeny in ‘ests number less ha (Le. we ow how fo ciige ete om speed xing chad [AERIS 2.41 Wh fur lines test se if th bytes te 0, ad skins 0 awSped they : ‘We then ned to convert thi number spit ver 2 bytes int 4 numberof ‘dreds en and ors so ht hey eam eile easily Ts wl be done ina subvoutine, awe wil have dot the Lay Speed section a wal To 30 {he caoerin we willl igtCamert AS the dipig t being sob we need ob eng diptysyontine mrp marae Unrate our {arefilyeseeraed mig loop sbove ean sceoramadst th ealing ot splay sebotne, a6 thie would ser lage numberof elack eyces ad op theming. The ing Yotne only takes G& mes he ea here 0 eave the plays ile fr 64 ms, apd thea et they rn for Dal second ‘Weick ina simple halfseeond ely rng cotting eer aking sue ‘ve al he Dapay srs daring he oo. Exerc 2.2 Whe the nn insretons Mich setup the tee dete ei ters andthe cel econd ely loop wba elle Dipiay, Wen ‘he reured tine as pase he popram sould jmp bac o Start Yu will tne 1 tke he engin ofthe Display stroutne it cour when Sing your Calelions. The ell instucon semally ukes tee een and he et insrsion kes fur, Oo erage, ce subouie elf wl tke iar tons, asume the whole sobrouine ston de nine foc cles the loop Cal be tay loop HatSecond, ‘All at resins nthe hgh speed timing method i to del withthe ootigh { sevon. which sip as oak the disp estes show “HT amber {Bae operation with ATS1200 and INTL? to Be dipayed wil be stored in resins elo Hunde. Tans and Ones ‘Thee wll be a oko ales ere, neg in sed wl beans asthe spb foran Wand IL ate yal for Pypben A T2 wl trae a lnk pee n0 same op, aos Joo tou etal digs to 12 jnibe nt secon, We teefae need to move 11 into Mundeds, 10 into "Tens anda | into One (a | look ean) od te Diplay seeing ‘vl othe ret Aer ewe amp ote lines befor the sare HalSecond Section hese thee ies pes Spe efSecod counting registers) exencie 243 Whar ies ake up he Toollph son? Sac ee eeer ert mete cP ETE ae icant stone Tes ode ei geet crt ate eae ee Say ae ee alr eon eee er a ent tee uateacviaeaaa tse a ee erences ae ere ere nies oan DightComert: fe Hundreds reset registers ‘de Ones fe Tens FindHundreds abl Toweryte 100. subrats 100 fom lower bye Soci upperbte.O subsets Maer bret Findtene does 1Dsifeare Ine” Hundreds increment numberof hundredr ‘imp Flndilunsede j repens FingTene sb lowertyt,-100 sad bak he as 100, Subl_—lowerbt, 10; strats 10 fom lower byte bres FindOaes does Tsifearry fine Tens Ineements rae ots Hoop FindTensst repeats but dose add 100 apn indOnes: subi Lowery, 10 jas ek the ast 10 Basi operations with AT90S1200 and TIYI2_ 8S ‘ow ones lowerbye number lf in owerbyte = ones re Mahe Yom wat ok or wy trough is pogam wih ape samber (€§ Coe yaa ho fo eed) Nada Se ‘hes sain » Dip Ths sw Core whch ee de ipo sven, appepinsnenet i enica Neos a sed ‘inn Inte ball nd nop neve wees ese {esau eee ne Ne cant mae eS are ne ‘he LEDr mnt eo tm lyon nd te apy no ak sisdows intersted appar ene wen opin ete fb nan vray of 50 Fe te sees ae sy hve dove ong 9 tc sn tn on te Sou ne ee Defoe ir rine ard hen pea Ts mens Si Stang ey 02 ms ohh frente Somer els ere Se fie chins deed shove eu my ish occas Seen ‘Ne ile eile Dpavcomtr Te il bee te ston shih oe 30, The gf pl tec ee DiplnCovter ed sce eal et es Danaea sete eed nh 30 Pare ean ti pre ee ‘eho ne Tat de tps and e Dablg mee Galea in hither an fie panes paar ec neat kt es soll Aeon sea eo ‘enh Diy sone con ‘vanes 244 Witte five lings the tan of he Display strong. Weed someway to now which dipy ve willbe laying and wi sore this as sumer tereen © 294-2 in + reise ealed Diplayhumbes ‘Thetfre. thf thing we do it ncement Dipl Number ae ete te H's reached 3 (you wil ako have to lear Dp Number she tnt [URIS 248 Wie the subsequent our fines of the subroutine which perform tie ow we eed do some serious indies desing Fst, we exch ight ‘uber be dilined rm Hence, Tensor Ones. You wl hve iene Sheth tp of the progam, I defined mine 8 RAG, RIT and FOS Tes, RENE Sete sep 2 pa R36 oo 2 ZL) dtd ‘unk is DiptyNmber, Ti wil pit oo afte te mambo ‘atttodpley Ulin the inset we lds voc temp. Te oes ‘pment py cas ae sored in renters RO-RI2, nd 0 we ew soe 1.4 RO moveo tot Adtine wo RO te mmr mos sa Ze 86 Bate operations with ATBOSI200 ong TINY? ‘he sven sent code ofthe mabe 10 be dplayed. Ags, oad this ae to temp, Wes clei 7 of Por ison aning Ka). Therefor tent offer & ii on, OR the umber in temp with Ob1000000, eng the ete ese ve temp 0 Part ‘panOKE 246. Wie the min ines which mapa be erect seven seme code Pon B ‘The remside ofthe srutne mus tum cathe correc sven seamen spl ‘Remember the exes of evebing te namber yu hve stoped 1 Po Bie going aa te cela bat beaming aly one of them on he sur ‘only apes inane of the mys. asc want tu on PartD BB ‘hen br, Denis and hen oko it 0 The eases wy this oad Pa ito temp, roa i eh whos eng rT creep. Ih 19 fe fie Wah (ue gone on fr sd eset va to On0000000 1. sence 247 Whats ines um othe cores splay a then rtm fm the boat ‘New lh seh i he low-speed sig section. We need se yp TCO 0 fur up eves con vce ses or mau eson), We sl nae 6 {rea ckarth se reise Del? and Dela pd ler PI to tno he HeLeD. exsnese 248 Wha eines wil sar fF be peed section? Wie need» may 1 ste when PDS changes (member now TICD ie counting ineraly we need est te ipa pin manly). Ther re 2 few metas ‘or dapotl he one! sper a llaws Soret nal value oP. and thes eee aoa which sds inthe ete vale of Pad nd elu OR ‘withthe inl vahe-"The effet ofthe EOR it to Might which bite Siem. Evample29 pogo i001 Ob YOOTOD00' ebm ac bi 7 and 4 were erent Wea ieesed ony in i (PDI) which scone the input and so fer perfoming the COR we can et bit of the anser a er looping | SUStiph When in any oop it as ang tne (0 is ope igh), ms | ako keep cling the Display rete. \ ‘tm store,PinD _jstores initial valog cor ore etore Inala Shs doen ep IF PM changed imp FestChange keep looping unt PD changes ‘The msn lop ofthe owsped tng section consis of epeaing te above ‘et foro shanzs (wat for oe complete period fhe pat oeilton td ineremening the higher byes when TCD overiows. We ded wih he 70 ‘erwin the same ay before, wth ne impern ifeence, We cat te temp ore the ane Bees emp is ued repeatedly in ihe Display "ebrotine weave jus writen Tis ery importa Yu lk ou fr thee ins fraps as they ean bea source of many problems ty to keep You ase af ‘edking raisers ea Ge: da' exes them 10 hld 2 name 7 log) inthis wy you can ws a ene lite temp al oer the program. We eam St Det instead of temp. sate end a loping. We att Dean 1 old ‘he crrent ue a TD, Before we eter he lowsped lop we pee to clear Delay and ICD. We wi als ped some sot of eure to cunt We uber of times te apt ‘hangs We ne it change only wie 0 up reper cled Comer Sholeed 2 io xe 249 Write te te petoopinsrustions Now the op las faa age ee ep inthe se wy sfc. nd Jumps ta econ eld Change ithe changes Exess 2.50 Witte foe nes whic perform thie. NT: One of| ‘hem is before the stat fb ap cll the loop Law Lap) then al the Ditty sebromin, as we ave od this eur ten test to see ifthe T/C has everowed. han’ verowed loop bak to Lon. Ieihaseverfowed incement Deay2 andi aves ncement Dl “Te minimus feqoeney (Ha and bence the maximum smote stout 4 00000 coon. which in exadeinal is OX3D0000. Thrfoe if Dal weathes SE we know the int equeny ito slow 28 lon 0 1 etn elled Toston: eerste 251 Challenge! What 11 ins forth the tet of the towed Sethe 2 ‘The Change sion should deement Counter, and loo bck to LamLoop if ‘nisa aro. On the second change, doen oop bak bat ised ec vo ‘ce ifthe stored number i low eonagh to dave highaped tesng. The Basie operations with 470051200 and TINYL? 4906 clock eyes, hence if he resis 4080 (OAD) of es we should ‘rancho Start td prform the highspeed esting Ie moy not be enily ltr ‘ow me testo se ifthe Tuber spend over the registers lst thn (OO0FAO, Fora arte camo aac the number, he would change te numba in te delay esters Instead we use fhe compare instructions 3 = ‘Bou we were js teing one bye, but lo mak se ofthe ep instuction, ‘sich orp to eters a athe he ene Dg seu Ts ‘Sm aralopoo to sebontng withthe cary (2s sbi butwithowactaly mpg the estes) The oly pole wth ee sth ony works betes ‘vo file seit, ota fil eiter and number, 0 we have to lead the orbes int emperary working epistere The neces line for Changes therfore Cages in sore For updater se vale of ort ete Counter waits for secand change Bree Lowigp — [dotstond change so ope Wel temps Qs0F setup temporary eters 1 tempytnoo 5 Dg iOsAD compare three number with be Dainaveemp +"bonFa® fe DelaStem? | tee Fo ess tha Fas eto high-speed sim Ste : “owl nti tinted of ti eget Hine re _Start) i ane {o Sartre fag rset we Soweto skip te imp Star eit ‘he ery fap cn These to mate ae eye ine ad ‘ub neta a? Te esos he fat tae ret {Suet bn oles wie ae 66 arn ay. The Str ee ‘Be farther ay hanson oe nse ite mp ee ‘hon Pens Iie hi be pe op wen you ty to ase te roan ‘ree tei nnd me nog ago On heat Sang 60 od ines whesever odo bres si into. ‘etn ove he ine prc he ula no ego Too it we med ake 0 Oa ede by the eg of tine dock te) ‘ete es menue fe meted 200 cst ees soe fod ths il eaespond to 0H Ther i nyt peroon ir lg dutty ite eto of igs yy ne Row tay nso inbred ve scion el le og se st #00 a= Ox9DO0N, send oe ee tengo ee temp, temp nd ten). vey tne we cry sue eet ‘rend oe Dey, ly? a Dea we increment we ye of ‘tive When overs we nee he per te The steer Basi peaton with AT90S1200 and TINYI2 89 een | and 10000 we nee aly ro byes fo the answer The ollming Tine se pte son ‘ai temp, 0x00; mover ¢ 990090 spread over3 Sat eampi, 0:09} "femporay repens Mi tempos} cle loertyte reset the aner eepsters fie gppertate | Xe 2.52 Write the ei ine ofthe lop called Dh wich vides {400000 the rember inthe delay seitee (in Cal the net secon DoneDividing and jump wo this secon wen «sutton wat wees (cay fag worse) ‘As with thigh sped section we then conven he pub in ower nd 'ppertnte is hundreds. tes snd ones We can sete DighComert so ‘i we hive srady writen, The Prost then lops back 0 Lowe NERO 2S3 What moines wrap up he low-speed esi oop? All that remain isthe sean elle TogSlon wich branched i when the Feria oF slain mee tan oe Sco. case we want ne ‘Splat oTand send he AVR tse, reRoae 254 Week de line whith make up the TouSn section ‘You wi bive to retemberto setup registers RO to RI withthe cart seven ‘gent code in th In secon As you save only the Il into oo ‘episers RIG-R2) soa wil haveto move he umber fit inte temp and then ‘ove ther io RO t Ri sing the mov isucion Als. een o tap Pon with oe of he plays Selected (e- 090000000) snd dene a your "exiers atte top of te program. should now be eady for testing wih Simulator. Thi may be worth bulding sy performs # wef fection luoeve, yu wil ote th is esluion i peat as you get ely tte gre resolion beeen 100 12-999 Hz tnd 10 kt-999 Ks You ny ‘ant think about ways improve the promam fo sve tee‘Rfure reso ‘on forall fue inthe given ang. In he coming capers il es ‘tod har wl alow so simply thi program hugely ad wi be worth omina tack to this atthe end and lef hack biotin he ‘Working on this ler program also induces the portance of taking bests. Even when you are inthe aon’ itis alaye a good iat back at few motes and ela. You wl in you etn looking atthe bie pcre 7 | [pa leee ere Ip rede such versight.Anhe ood pce of vie otk 19 pope ‘Shot decison yo have tra, or poblems when yu ge tye Even ey |) dae knw the fist hing about mircontlles, snp king the ques vel ping often revel eave, . 3 [ntroducing the rest of the family Sof, weave bees laakng athe most bse yes of AVR he 1200 andthe ‘hay AVRs I wil pov introduce some of th difeences Samet the and ter AVR, seh nh sbseguent apt tey mish spear more fale, Other mods may bene fom exra menor eed RAM. The aleon oF ‘menor ifr ifernt dl, alls the rangement snow fn Fiewe 3.1 [ ores 0 REGISTERS: FO.ASt v0 REGISTERS. $00.49F Raw. goa “The fist 32 adees te the wovking reise a the nes 4 are the 10 register. So the key dierence betwen those with RAM ad tose witout is the presoce of fer memory aces fom SoD onwards. These can be sects ing th 38 od at command sed) induced md wih oer insroctions now ale on hese mere advanced model. A significant ( 92 trading he ret f the fii chang othe working registers eth invoduton of two more 2 ese See alison o 2 (nade upof R30 and RSD), tee now ¥ (ade of Ff and R29, and 5 (ade ap of R26 and ROT, They canbe weed i ay Franti tbe 2 (or Hy }pm a) "Wns ne west deleted evel sack on he 1200 and Tiny AVRS, tev tbr mols equ tht you el them wherein he RAM you wan our ‘Mocha be. Tis mean ts Pseily a8 Sep as the RAM adress space ‘ough avis you maybe wishing wo give some ofthe RAM adress {nore lamorou purpose, Wht we wl dos make the last adres of RAM the {ep ofthe sack. fn sway we hve what eas ike an opsideedown sch as ‘Bown Figure 32, which work veal he sme way as ay ter stack "AM. “The UO resisters SPL and SPE ae the tack poner resers (oes and igh ten and some move i thes the es aaes ofthe RAM, The ‘apts re frm in he nde file ween at he to ofeach ogra 5 AMEND. We thtore ld the lower Bye of RAMEND imo SPL and he oper bye imo SPH, and thar pint the Sack to the end of the RAM. The Wi temp, LOWRAMEND)__; stack plnter punts to font SPlntemp Pas RAM adress Tai emp, HIGHRAMEND) | ost SPH temp : Inrodacing thereof the frily_ 83 eves vit ony 128 bytes of RAM, RAMEND i ony byte lan, othe ast ‘ones giver above should be oie “Arohr major iference een inthe ober mal a gester set ofinstruc- inst you ae sven reer ley withthe Id ands insusions. You an make he long reper ot Z belgie as anaes ptr suo ‘macy increment or esement with caeh odo operation Ma regulongreg “This nds tbe memery Joon pointed to bya double repter Ge. X.Y & 2) foto rend then aoe OEBIg. “Tis etracts one fom the double reper. Y of Z) an then loss the emery locaton pire otha double rept int rep Thee are nao our nsucion fost. ‘We a we this sboren our mukipe reser clearing one. I this case 1 hve hte to ee X an the crest dress pointes hit routine eles repre up 25, ce XL gelearex Ge OXH |: eearsXH CCeerkonprst| -XILX+ cea indirect address and increments X co X26 j compares XL with 26 Bene ClearLaop_: branches to ClearLoop ZL =26 Other exhacementsolaeeore operton ini srogtanmber ‘This ods he memerylcton pind wo by te Yor Z regis ito rep and then adda number (0-3) 19¥ or. Mote! does wart wilh X) Theres ab quivle esac for sterng. sd, which works in he same ny. Ther Bbo nyt vet aren emery inthe RAM: are 1s regs mumber “This th cots of mer teats ven by member ino rep ‘Themmer can bbemeen da 63595 e-p tn Oa). Snel ees Seer ina reper os ey pei inde pe Sn el te parcry stl and ae specie by the sonberie Ge rege cnn ell scale de nde niet mee ia 2 94 _Inrodocing the res fhe fly Example 5 We bine pos tht ha perform one of Sve differen fanstans depen on te namoe i 2 repier called Function, By ang Furstion tte arent alu of he prop causes, od fmping © sdhres, we can ake the program bane to diferensetons ae Zt makes sre higher te lear Ta ZLdumpTable_; pints 2 1p of table ZL Function Saas Funeon to Z ively ums Timp empathy ‘Addon jumps 0 Aéehon section Soveracion {Jump toSublaction section Maltptcaon — 5 jumps to Maltpieton see Division ums Divison section Power ump t Power section sie ths! JampTable load ints Z his isan ye eee at {he proprm munary dna afte fp i abling We do tee iiaiae Zt aint tthe top f he branching tole (emp Aten). Note Ua {oasing sumpTable = eguvalen ensuing PC'S. The name in Funetion ie ‘hen aed 2, so that he number in Futon (between © ad 4) wl ake ‘he progam o one af he ive Seton "You will wo dot emember the rumberfsdons nd subrcions we had to do to 29 murber inthe fequney counter psec Here ae to Snsrations th ny el ly lenges, amber Siw lenges number “These add or subtracts number berwean 0 and 63 tam on ofthe 16-8 {epistes OLY or 2), The stands for word (16 is) there is ah oer ‘cary Sis ately transferred gt the Bighe Woe Hence > » ae “The two remaining insractons ht ate Sed othe repel ofthe more sane VRE ae sl x10 Bel XH push reper Pep repster ‘So fare hve nly been wing he tack forthe stoma soap of progr ‘courte adress when cli subroutines. Using tes ston, yo ck Desh oc pop tie munter in any moran einer on or of fhe sack meng Tres ee family 95 ‘Evanple3.2_ We canase the push and pop essuctions to eae a palinbome dae 4 alindome is esetly @ Syme eguece (ike “rt “denis sine’ ad evil lve). We can massvely splits prebem by lsorequirng tat eae gen he length othe ip sage, We an we he Tenth oid the mile of the inp We cna ase ta th np i fod (Gem ASCH characte) in a eise called pet ASCII sa wy 0 asl Jeter ad sya ina bje, so exch lene coresponds oa partie Tong mmber Se eleeively wear locking forthe Sequence f tye fe nto Input tobe pidromie eye) We sty pushing he number in kaput tonto the st, We ofr every new inp unt we ech he balay Pom ‘ethene poping the ck sed comparing vib he put As longa e22h ‘sw np ene oe hese nthe popped number, the seoence ie ‘analy pina, If he new input fale 0 be bese athe popped uber, we sect the input sence, Pin, bt O wil pulse Nigh for [rsecond indicate ow np syrbel (ve eed hs because we enna {iat at forte input symbol shane hit would ot reson to epesed| Teer Fir we sume the length ofthe word stored in Length. Thishas 0 be sided by two ogo the all> pin We wil Rave ake 2 nt if the lenis or not Tis ir done by testing he ery ag: high Length ‘soda we hal the TB Sart: mov HalfLangth Length; dvies Lengty by 2 get ie Halengeh ny HalfLengty ie temp SREG ——jcopies Carry ag ino T bit te temp 0 Teac cir Lengeh odd Assuming he ir ipa yi in Input, we pth t 09 the sack ad shar trait forte pls on Pin, be. Te pulse sf miroscond. so atsning @ {Di lot ma betes tes ce every four eles Tne Semmes Uelon teed ane every her eels Fra posh input «pushes Iapat onto sack Pues $s Pind, este for pte imp alse hep looping ‘Wen ape seein em ip eymbol i ey he program incre ren Counter whieh skp mack of he apt umbe. I compares hi Tuer sith HalfLength and loops back along 3p Counter i es thas alfLengt 3 ine Counter counts the input amber Counter, HaltLangth compares wit hal-way value ro Firstar ope hae te ae and peo ST ‘ing he rt fe omy ‘hen Counter equals HaltLengh we chock the Tito seth length of te Spot sod even IF 048, We Rett poe he mile lees, sm eet, STi nd lop back to else wich val wa sal he ent pet italy If {Be lenph sen we can poo wt he secon bal fhe put brie Stconstialt tet Tit eh $ dears ie fimp Pate : ‘ee nw posed the aly pin in the sequence and ow the ne ipa SMES law match the previous ones The top of Sc fy popped tad ‘apa wh he errant put IF ey arent ea the Sequence ejected Seconda pop Input. Sp tnput Inpoee frme eee 4 pops sack inte lop {compares iat and Input. |) as befor, we then inerement Counter and ttt ate if Counter ess ‘Sage tds: he sins ver and we can acco the ipa fe ven seen the ea he progam ten i fr he ptt change and ineg bah Seconda inc Counter. count the inp number Cp Counter Length compares wath otal length BrogAecepe nd of sequences accept }pusea: sis Pind, imp Pate? fimp Secondtale loops back wen ne inp is ready ‘ugh wnt play around with hs on he simi. but don forget set lb lpn sk ss esrb tthe tt othe caper Yo aso et 10 att how to remo he oeed to be gen the length ofthe inp ‘Squence Ion want id on mre bos i yoo may wa id beck (Forma Langues an Posing 4 Intermediate operations Interrupts So far we hve alvay hat est for etn eens ourselves (eet for 2 buon tobe pesed tet if TICO hs ovelowed ee.) Fortunately thre ae 2 ‘urbe fees bith cn ional alert us when they oct They Wl ‘corey at up nterap the normal ang of he pep and jum 08 pci pr of he rogram Ths eves reeled erp. ‘nthe 120 he lowing iro re sb neste wen se INTO pin (PDD) is ow Inert when tere eng eg on INTO Inerrae when the ia fain deo INTO Inert when ICD overtone Inert when the Anaesue Comparator ie ‘The fr the conti an eer ier on INTO, dae mally exh- Site le you can emble ony ne ofthe the inert at ny one tine). The Sipnfiage of the Ancloque Conporator willbe Gscssed eon in the ‘hale Web an rrp ecars, he program wl ump o one of te arses te soy ofthe program, These sreses ae gen hy whats known a he inert seco ble The inerrp vecto tbe for the 120 is sow in Table 44s the ales forte eter AVR pes ar shown in Appendix “Type of nterrapeat Program jumps adres Poweran/Reset xco0 -xeral itera o0 INTO aor ‘TOD oe rept (002 Anslogecomparvoristerype ———_Ox003 For example, when the TICO seiner is Gable and TICO ove ‘she prosram dops wat is doing and jumps wo adress Ox002 inthe propia memory. Wher wing al ew intr he sa of te proeam onl lok something Uke be lowing: 98_Inemedin operations ver tn Gest ne eeeated simp stint ‘handles exteral inter Fioop Gverflwiat — j handles TCNTY intereupe Bmp ACI handles A. lnterupt “This wl ene the program benches tthe eet eton when & pale Smtr ccs (ew cl hse inter handing ovine) We cn ble {naiidual interop sing vas registers. The ene bit fo the External INT inerrgt is it 6s a9 VO reper clea GIMSK (General Inert ‘Man Seting this bit nae the iterap ceasing it bles The nae bi forthe TENTO cverow bi i it | in he TINSK TO reister (Taner Inerrgt Mash). Honever, al of hes iter ae overiden by n ine ‘pis aste enable. THs ee maser sviteh which wil dale all iro: tite ff and when on teres aldol abled errs. Ts ts ‘he bitin SREG (ou mH want i lnc bck pase 2) “Fe Extenal IND itso! can beaten one of tre diferent exeunsanees, depending one sates ob Oand | of he MCUCR 10 reper (eh one hat ase slepseings) Ts elon show a TB 42. Tate MCUCR Interrupt occurs when Bi Bie 0 0 INTBistow © 1 dal stem 1 0 Thereiga fling ge on ITO ht Thee ig ge on INTO ‘Wen a ner osc, th leo program coumer ie sore inthe stack at ith oie, tthe popan ean eet er Wa WER | the inemupt badling i over. Furthrore, wer the fterpt occur the ‘mater inarrpteable bit is eunnacaly cleared. Tas sv bat you dot ve intr ering nis he ity unig rome which woul then edt 2 mex ofesrsion. You wl peabby want een the met inert bit upon reusing fom te inecaps handing routine. Four!) there purpese bul srctin: i : “Tis returner 2 shrine ad atthe sare ine nae the ste et ragtbi Each iter lo hasan interaptg,Thi is ag () hat goes ih ||. wbenan aera shoul coca even ithe ll ineruts ave been ed Inermedae operations 99 and he appropri interop service routine eae he gle nerps sre de fer example, We are already ina iret nerrpt sevice etn) you can est he age Fay irra have ocd Note that he fg oy bigh ntl ee, and an itera servis routine wil be aie ag hgh ad the elbal trun seated So you mires ll age fore bling the alba inert bi, jan ate you have some inert age lingering high om an even ht occured previously Inert laps re eet ‘yseting he pproprite bt = hs sounds counenuve ut the ay ‘things ae! Te Tcl Over itrup ag efound 6 1 of HER (Timer lnverop Flag Reiter ~ UO ner $38, ard the INTO itr iain bit {Gof GIFR (Gener Inerap Flag Register UO number SHAY. Program K: reaction testor fe Inert 1 Random number generation 1 seven segment dle ‘The nest example progam wil be renson ee. A ready buon reseed. thon an LED sil tm on 3 random tame later (oughly besween 4 apd 13 ‘scons. The wser Bas To pes a bution when they see the LED turn on, The program will mesure te Faction time of heuer ane dapny in mies ‘nde am hcx reve pment ple fewer proses the ton beet CED tus on hey wil be nupteheaog The eet iagra fre projet ie shown in Figured |. andthe flomehar in Figure 2 ‘ie wl be wing the Exteral INTO and TENTO Overiow interrupts 0 you wilhave tw make the sess anges oe op ofthe program, Not tha ot %e wil pt teasing the Atelogue Comparsor itera we doo ned ty Pareaar isin a aes OXON, evens 4.1 What the fit sae intrtions of he progtan? ‘Wt the rt secon. seing 100 to count interaly at CK/I024 You wll Ive to ene te External INTO and TICD Overow interop bt don se ‘hema enable ot yet Sette External INTO ner to eee when INTO ‘slow (when he buon i presse). bxmnese 42. What ae ther ne which individually enable the inter? 1 Start we fir al the Display shouting, an thee te "Ready bor {Pd} Rep oping wt be Ready bo sped [HERE 42. Whit elses aie hie? —————— —| merlin pertions_101 sine ‘The Display subroutine wil be alates ike the on in he fegeney une rose. The ony diffe les nthe els of he correct py Instead fasting Serves bit se 2 of ot Ds pa ofthe sbrine ‘wl have rate Between bi and i testing it ose when hs gene {oo far Make the necessary changes tthe browne and apy in, We naw ‘endo cents random tine delay 102 _hesrmedaeeperaione Imteredite partons 103 na ‘en 90 fr ff 128 (0 in fat 122) Our fee made lot easier dietnc is , 128,05 tines ended re quoted only a apposite we ae (ne ofthe ineresting spect ofthis program wl be the eneation ofthe nett ges on 600 i vr I | 88 wc wit peor seat To ome or fandom me's pede a tie ey of random lent Te mat sie Totem ner cs easy em ase Tecan «i | {iow met lx trang nom meio rel oo se mah Op ‘etn the progam, will a eines Rendon bags ram Sd comer sts uber or mp ie oud ook ember 9 a a ot el Ral im THCO wen the eyo reseed TIC, ering tery, wl be Pero : {ouning wand ettowng canny, nd oe vaue whe te baton | eset berm. Yeotnbmees enti! | yee 44 Wha in wl ent eon anne ‘oman inn onda we he Yo eee ata frend tuber. How 6 thi done” There alge suber of algrtis walbe for everaing—{gxenege 4 What see i ‘Shion nome vring complet We ert inthe aplenty of Seca nora apy ie AVR sy hut amy of te tine spc on tn | ents te ihe oe iy ie mo gin toahpietin The Lier Congraeil eth deep Leta 1983 (See Ra ao in Site owing fom: an ero Es will copy-Random ints CountX. cide (Count yo, sn hen 83 60 Igy od fe, 0) [MERC A Which sins wil eet Tel, Prt andthe inert aps? ‘is gees the nest mer nthe Sequence ipa the prevows Ime bye ding hd ning the resi od od wth ‘aide ef when you des by me Conreiely ere of eer ope ‘Theres para nsruction fr sing the master ner ese son pater ne AVR pr ecto a male 28 Fe “ Ba pi a 00 28 Trl ma grcteweer temas | re oa on ie poh jae ores mg CoddontecnctatscinacsiC em tutta henson [lettin ta entre is ec akon Ent INTO ier, th maser itera bt wil or eenae nop a, ‘tui the tera wil lop ack o Start In cota, shes ICD reed terete ners wil renal te program wil Say ace, tats be ecco he faeces Signin tw be sen main) wel chore Sade. “auabobare ope aee™= he mt morhua ‘ss nl op on pends anf came te qashondon prope. Frat you so ote ate nonsense oe 20 ape ‘Senet oe pa ne Yr il 2ho esque pes een 286 onben ts inan mores] iMEGat ie Va oerow age Tg. ne ac rope aie Png per mals vi nee be pe sie mir LED an eon ia espns: Ne cusig mao Sy goed ct em oni atmo i ea et: be met Tar wont wine | igen emg ie fey rei ‘Semorina ty me Fp woe | miu tan lpn ee we on {RERGSE 47 What he tns finish ofthe main body ofthe progr Looking first TIC overow terug handling rotne (Tn) we see that SEivic dpeedeft qe epunie PEO seme 0 Teemarailasermras stern eto se ntowag ne | te Os emg St ttm fete mtn ine 0 sean dt TCD wil oeow evry 236 com> {MEME Dia wel, WE ned coer hiro mend someting sae et nt" wl ome iba ake |, tag ot 1 ay ee spi See rer bce | Mat en dey Aig ee foc 9 fe meceiaveoiciaetmectctcmnces tos | | Ss Ths esy i doty sing HD oad shes Beg GN —————— ee 104_tnrmedat operations | | ren subnet he OxA2 back ofthe final aaoer the ed ofthe dy tess LED $a eiferent section fon Tie able PDO ime Tint LEDon uc CouncX = eerements random counter req PCH? ‘Speier ssi PortD,0 stores on LED when me passes Hnlunlaes TCNTD to OXAZ Ho faciate testing or max ak temps xa ut TENTO temp Tiet LEDon ine Tiel neramnes higher bt hi Timel0s08 jax fer maximo time reg PCE | Ships the wer 08 sw rel Tah Kunde. 18 tai Ones. 1 ‘The Exe INT erp handing oie nore sitar il 2 Fehrs mbes sn LBD a rons SEM ted resign blr tbe LED has ed on In Serer Tl and 12 Hunureds, Tens sod One sa esr Cpay ‘DA aed ten ren ww rea he tic Ite LED sone press vald an 0e hve at See ee nee moving 1D ine Ties psi eee tr he THO over Ju feste HOO tera re Seater net oe he CD over interop Ma. an ee ct Miia Ten he ool face ie (pu ev ie nd ‘Fe tar hve OxA sac om (ns was eral ae) Tint enemies Sand ied by 12. xencse 48 Which 12 ines tthe LED atthe star of Extn fst be LED. [upto aatton ead Chest if is on and fat he TICD and store te Meat valve, Ieetening Timell sf necesary? OXA2 shoul then, be Sdeased fom the toll Teas fine, and TICD shuld be rested ot exon reenee 4 Whi ries form he Chet section? Inurmetat operations 105 ‘After sutracting OXA2 we ned to mulipy the tine by 5. Ase ie is spit ‘rer egies we need eth ade f848 nr the isher byt and ‘hea theres cary Vai Coumis,4 Hada counter with 4 ‘mov temp Timel stores me in temp and tempHt mov mpi Time} Times: NE temp, Time adds Timel wise fide tempi Time} adds Tiel and Carey tse Gee Counted does this times bine Times 3 ‘Te prove enw held over temp ad temp, Wethe vide theres by 12, ‘The smpet way ths a set bow many ines ecm bret 12 fom beta xe .10_ Challenge! What nn ins wl filet Tiel and Time tthe emer lop hich des he byte number sored brace emp a {empl 12s he res Time, nd Time, (To sip ov fh Toop Jun the DigitComer seen) DigtCamsertcooensthe ye number in tee dig number tis soned| fem crc aoe hg eg nnd te retinsrson athe ed oe secon. we np Star, ‘You wiltave tose pate ester (RO-RIM) ht ld he seven segment ads in en setion Registers RIO. RIL, R12. RIS ané Rif the codes fora 'k, dard respec Yo ean doable ec you've dane terything evetlyb looking at Program Kin Appendix I soul be gute fento wy tis one out Of course the simples way ef sng an AVR 5 ee: ‘in serie t ea rnd tbo between ou gers and rp i sd en {ero ar don he chip you coup Analogue comparator ‘Arther wefl feature on most ofthe AVRS isan analog comparator (AC) ‘eich conpars the wolages on 0 pit (called AING apd AINE ~PBO and PBI onthe 1200) and change he sate of bit depending en wih vag s ‘reer Tht alcool by the ACSR UO reise, whose bt asianmens Ste thowa in Figue 43. 2 Bl 7 siya ct vic fr te AC. You sal de Be AC rept (ces bit 3) before ling de AC otherwise a tert might =r ‘ihe you ty 0 ech of Bie Oi 1 ite what pues an AC tert {ners of te AC ru (i, tr when the AC esl changes, en | aE 106_tnermede operations OSH Anne Comper Conan sane git freon Fame for | ace ince Cm crt Antanas Po Even Wet on eon Cann On ‘Sacre Campy OFM pm seman Program L: 4-bit analogue to digital converter © Arslogse epeioe es poet evry mach a ee of ing wt ou ct with wt 00 Sie Soot eh nr Soe Roe io mine omen and nih ee yeaa 38 comer 8 Ey iia Hier say AVR et fom sao ‘Siete ih ny acpi ce rig poe Sa bevera They tots ges nga omg phere Intermec operationt 107 of 16 poste reference vages. By rng rough these reference voles sed comparing thom wit ie inp sg, we cn deere te lp age uh eatin nd wii four les of elo. The ea agra shown in Figure 44, pay parculrstenton fo hom te suring eerie ‘wks, Foe mor information on suming anal, eee eek ae ‘taghforvar towers shown in iste 43. PDD 1 PDS coral ch efrenoe a ss sunmaze in Table 3 i bin et he comparator rr or aay wor Say. ooo easy wo Sas oo gsnv ton any om pasy. qo Sav oi Hav Mot Sey ono easy mo S3isv omnia mit Sev Write te nt eton. remembering to tn on th analogue compar by sting bi? of ACSR Leave the AC era ef At Star ees Pond ih 00000100. This ts tbe mos significa bt of he vge slag thet fends 25 Vion AINE This ther compared with epee np is ihre the reesence, bof ACSR wil be high, thre be lll low Ie ings her than the refrac, the ames rer sae 4000 ands we lve bit 3 ofthe reference high ands! ie Ifthe ape lower than the reece. the answer ies than 100 ands we det tad then st. [REACH 4.11 We the fre lnes wight up Port withthe ii vale fede the AC rest the AC resale cer Ba of PotD. Inca ‘uses of Pa HERG 412 Repeat he abn forthe remning bt elt merlin XERGSE 413. Chllnge Write the four ine a tense the renuhing ste ‘ PDOS woe outs (PT), nd then fup Back Stace Stow me Erne Sr MW Bio 97 eT (| | i | / \ é 44-bit OUTPUT 5. 2. 2 ee 10-bit analogue fo cial conversion (ADO) (ther AVR modes sch asthe Tings. 4153 and 8535 hae = bin JO ‘AD convene. This works in much sae nay asthe comer we bat nthe previous section, exces al Se fr ws autoraticaly te merely, ‘Tee volageon oe of he arslope input chanel messued (th apt the volage ofa refrence pn AREF convened int 10. buy sesbes tnd sored ovr too 0 reise eaee ADCL end ADCH (whe sad oe AADC Result Lover byte and ADC Remit Hh te Thee we ro base ‘modes of option re Running ao Single Comrie. in Free Rasong he AADC repesey measures he apt sigal ad onstamly ites ADC, aed ‘ADCH. In “Single Conversion the wer nine vey AD somisoe Pemscives For the 433 and 8535, te pi ing read selected wing the UO register calle ADMUX (S07. The bit assignment i thon in Table 4 al oe Oe erased 1 you want w fet numberof chamels. you ean change the ADMUX. ‘spit and the cael willbe anges needa AD conversion isin progres aferthe comerion comptes Tis meds youcon stn cash el in ‘Fee Running’ mode more es, a you en change the cham ing oe conversion, and he ext omersin wl be on the new Come ‘Ths es of ie ADC setings are ld he ADCSR (ADC Status Regi), WO reise $6. Toe bit signet ar showe in Figure 4 eh CO | su sorta pate | = | ADMUX bits 2,10 Analogue taput +400 chante 0 (A) ol Sst (PAD) ~ qo, Grane 2PA2) au Ghanet 3 (P83) roo (Chanel 5 (P44) tot Canoe § (25) 10 (Cane! 6(PA0) m (Chanel ?(PA7) nerd operations 11) Bit 1 2 contd he faquncy ofthe ADC clock. Tit costs bw Tons cach conersion tes so the seu ofthe eames, A cock Detach ‘SD rand 20a Rroconmeded for fil, 10-bit, eeu. Fgunces ‘hove 200 Lean be "en i send of conenize is mare import he ‘sccursy Frxarpeatreguenyf t Me gives Bi esclton an? MM {Pres 6 moan Th ADC complet interaptoceut ented when ‘ADC cusersion has ite. Te ther bis re sah Orv “The ADC on th Nag lighy more advanced fering ees ue at ners reference voages and ferential comersion (e mensrng the ‘olage ciference berwen wo pis). Moreover, inthe case of the #493 and 3538 the 10 ADC mu is tre with the lower tye in ADCL and he ‘eng two msb3 in ADCH, In theese of the Ty, you have he oie etecn ts arangement, a string the wpe byte im ADCH and the ‘emining two ubN ia ADCI., These changer lake place i he ADMUX ‘egite show a Figue 47. Lostng a bs Ot 2a, we Sethe option ook atthe vohag ac eteen pins amd ADCZ (PBS) and ADCS (4 These pas are pot Troughs crea ampli hen ensured using te ADC. Theil tl anpiierca eter have again of or 20 You wince tat two oF | {he seings give th iience etveen ADCD and ull Ths is We for a eatin purposes, asthe dierent amplifier asd in the derece sting will ven smallofict. Dy messrng his fet and suring fom the aan of our difernce mesures, you wil improe te scars: of Ours “Auather hay featweif you are intr a igh secu converion i to send he chip 0 slogpand prt an AD conversion his moe. This Trips mint noise em the CPU (coal proves ni) ofthe chip. AN ‘ADC complete inert ean tea be wet wake pte chip fom Sle Thi ‘tehoddemonrntein Example ample 61 ai emp, SOUMOIOLT enables ADC Single Conversion ADCSR,tenp "| enables AD Complete Interrupt temp, BOM10100 enables sleep, Meucr’ "AD Low Nese mods . oe ep ~ this automaticaly 1 Mtrte AD Comersion ‘When the AD convenion complet, the AD comerion nterap routine wll be ald (aes 80080 the Tiny, an agen SODE on the #93 oF 853), he ea rem fn te in wl ery on ne ie er 112_ntermedit pertions MUS nos Munsee 37 [Fase “Insermetine operations 113 tering he voage ofthe nalogue ouput. ft eow a cerin mas the [AVR capo t fmed on aia top up te ualogue op To lower the osloguevolige te AVR apt Is lest to to dshage the cpscoe “july, gue ler techrgus auth he aged of fil upat is exageraee [9 ic rogram M: voltage inverter 4 Analogue digialconvesion 2 Digi to anloge cameron ie can use ADCs o make gal arsogve conver The trick hs ist | ue the ouput charge up» pac ani reaches the vegued ouput ‘olage. The AVR oat the goes open cult (urs el naan inp Tae “spactar wil then sony discharge ough the inp impedance of sever ‘Steading lowering te analog up, Meanwhile ater inp is 00 F shouts be made snl eatugh wallow quick responce tne, a C high ough wo gies sooth oa: We wl eons this with» pre hat {Skes an ip Setween Om 5 nd tpt (Far example 2 Vin becomes 3 ot The crt apr shown Figure 49, andthe Noweha figure 410, Tee It eto, we wil hve a eable AID conversion, nd slet ADCO to san with. We wou ke minum aesuracy. a so rege clack pod ‘tases han 20k Wel e using the eral ear waich rns 3 1.6 Mila This ans tht ax ADC clock of CHV (20012) wl be accep ‘Tae ADC shouldbe sngle modest he "Le Asis tat he upper ‘bj ofthe ADC ne sm ADCH ad the wo Bs im ADCL. Fal et Vee eo ete om, selstd (by clsing ADMUX, bt 0), sd an AD comsson should be sare | —, +8 {by setting ADCSR, bit 6). When the A/D conversion is over, this bit will be ‘ered e can Is it ad Wai feast. J Ht i i cr | xcs 5 Wa arto stron ND cameron ADCO Le, output The ‘once ihe comerson complete the input voltage wil be tor in regisers [ADCL and ADCHL Tere nonce for the fill 1b agra el simply re 8 bis, Wh Left Adjust eae his spy iwaes ning te ‘umber fom ADCHLTo perform the fnsion (pu vllage) we spy Inver the elt onertecome ors and vce ver} Inver Ue ele usin he ‘com istration and store the esl na working fee elled Desied is repent the voltge we wanton the tp w ewe EMERCISE4.16 Which instructions store ad invert he easement fhe ‘np wolge change nat channel slat ADC, nd wa 3 mew cove ‘lon shi lr ait in lop he ere converson ise, Now the wllage en te opt is Bon we ae can Be compare Wit he dss yolage, Savethe messed voltage fram ADCH io a weg eater fsled Acta (eam oe om the cps). Then sth ames (ep and Tanebever (hr) isrctions 0 jump to scons cued Tollgh ihe seal pat ishighethon the dsr up of ToL ow ihe ata uti Icsethan the deed east) XERGSE 17 Which seven tines pefoom these tests and branch cat 3s to regued? Ibe acu and desire voltages re eq, PHD shoul be male a8 res "apu by clearing DORB, bt 0) and then the program should amp back 0 io Soe 7 Yes ‘The Tolligh section ced to ower he outta PBD i ade a att (imaseose teseribinns | | Qyseting DDR, tO) and the mado OV) to deharge fhe eapactor and Ly * Tobe the ouput TaaLow neds tose te up and so PBD Teme a8 erp and mae high (SV) charge up the epaci Pwr [xenest 418 Wee hes line that ke up th Toltigh and ToLow exons The end bth seins should jump bac to Sa xekese 4.14 What munbersshould be moved ito ADCSRand ADMUXS | Tht wraps up Progam M. You may woot expert itl and ake the the it cto? ‘ivi pvform mow complicated fonctions ca the ips, or pethaps ot legs. Pape youean make ome frm of ado mise Y sxmming 0 pt ‘Witte whe ofthe rt secon. aly make PBDan opt PS andP22 |. met oe eae ead High hols sy elt gt ‘hould be inputs, Once the AV reacer Start the ADCO chane shoal IE poudetnercnd somd atpa Aru can se, here ae a masher Oe

Вам также может понравиться