0% found this document useful (0 votes)
5 views

Unit -II

The document discusses interfacing external memory and peripherals with microcontrollers, including timing diagrams and examples for accessing external data memory and ROM. It also covers keyboard interfacing techniques to eliminate key bounce, LED interfacing, and the characteristics of embedded C programming. Additionally, it briefly explains real-time operating systems and their applications in various fields.

Uploaded by

sandy243154
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
5 views

Unit -II

The document discusses interfacing external memory and peripherals with microcontrollers, including timing diagrams and examples for accessing external data memory and ROM. It also covers keyboard interfacing techniques to eliminate key bounce, LED interfacing, and the characteristics of embedded C programming. Additionally, it briefly explains real-time operating systems and their applications in various fields.

Uploaded by

sandy243154
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 26
C PROGRAMMING! 3q rtfact —— Memory qn tenrfac ur igynepsis * ye Inte facing and ‘timing eliagrarrs for me rnony interfer ( — Extesnal pegream memort External sata memory ~ M Adele. 2 ic ) ¥ lemony : Ss pecedt ma / paler peg not le ¥* rnterfacing Examples # Accessing External dato memory to gost c. ref q ee tS bree faterfactrg and Timing diagrams for memory Grterfactng - - # @051 has internal data and cocte rmennory witha Lirritedd my we my Capacity ray not be Sup ficient fort Sorne appicatio?- € External Rom) EPROM and RAM Connect Crerente ly OH # ROM is used pwyrarn mly yRAM iy used data my, Extexnod program memory « _— amaporene™ ER pin is connected leo vec - > Progrera fetches t faceleerses 0000H HRrough oF RF ose oltrecked bo linteanas ROM 3K 1DOOH through FFFFR aw directed to extern ad Rom/EPRO program memo A kopus Fatornat ho Do Dal Rom | EPRony BL lad é_| cele ie Fig: Accessing externa} Proyiam memong % FB pin Bs orounded, alt ackbwss ( 0000 to FFFEH), # Pekched by program axa cliucled to external Ron /€PRon, ALE Psey —— 4 >7— : Pero extend | ' rnereny ococH |. i | [External data | | ! yf | | | | | | | | | { eis w Addarer’ upto by kbytes af external data memory se "Movx” nSkeuction tb Used to access externa) ¥ B61 Ly alivided into thnes blocks : D lower 29 bytes > Upper t2e bytes - 3) SFRy y / pee / Psém —__/ EN wor Go DATA. 4 a me ore REX SET Post 2 CBS ET he Fen SCS Fi 3 ol Fig’ Wowoferrms (ort cyte ) Memory Adldbxors, ecedling ; ¢ : . . Bleu Read [write mermovtes Constets of an arvreuy of api ain wh®ch each Hegisterr has urlique addtwess. port 0 Sito of memory o> NxM, whee, NS No.of. igkers. ™M -> Word ‘lengty. 2 as pécomple = ag, mernowy ab having 1 aleve Aeneas and 3 dato [Pres 1 No. of: negisters ae ‘Jocations =sajoN { : as word dength =m bik, = Ho. = Q@-bik. memory capacity, |adotreas Hpes Reguitved Ik 21024 rly Locations 10 aK 2 20Hk ” " AKaheWb ny, 1a Sk=8)92 « oy 13 % ‘ IbK = )b38h » ” y Bak =B21be » nS onk 565638 ,,, 1b memos ‘interfoctn.g Requires 10: » Setect the chip. 2) Tdertify the seqinten 2 Enable tho appropticde buffer. aye dete. , i lo-—_ wR i input buffer a ere | ! hoqbxe RW A = 23) omy 3 |: | A 23 2048 XB [5 | ee |G CNXM) 5 | | ; m eosre MAN Actescing Extetno) data memory tn 8 ; Uses Fos accessing external memory Qos) C 78, Command. 1 loc gives —» Range of 0004 - FFFFI Toclude absacc. pr “heacler fe. Eocomple : write an 805) c program to Stove Aso); a for numbers © toa th tho external RAM a op, Solution : AR include < veg 51-h> tH inctude Zabsace-h> Voicl retin (vote) XBYTE Lod ='p’; XBYTE LY =’; x BYTEL 23 =o"; * BYYEL2y ='2", 3 {nether Escample : inctucle Yeg sih> HEinclude 2 absace-h> Cid moth. Cvotd D i angi gnect Choo Fs for Ci=1000 3 1< 1005 5744) Pl = xBYTELTY > As rio Devices anterfacing me ‘es 2 2 no pstS 5 3 # Keyboourl Interfacing . - key Debounca uding HI — key pebounce ustng Sluo ~ Sfmple kay booed ‘terface — maby Kayboord Ynterfoce # LED Tnkertfactng # Multiplexed) “1 segment Sbplay Inter fact og Led Interfacing . a ieeyboowe! Interfacing : = push button Keys OxR udeck . - push button keys when pressed , bounces o few times 2 closing and opening. — Interfacing Keyboard is based on rivew procesor /contwlley . - Reading taken dung bouncing periecl may be pouty. —wokt until tho kay Feach to Steacly Shake; thik Ys kouon od Key blebounce Logic 1 +5V Logic —_ | \ R lee | i outpuk . | \ 1 ‘ VV\ Logic 0 _/\/ j Key Key pressed pressed Fig = Bouncing of kay Suktch. Tie. problem of key bouncer can be elinfnatect using Key clebounce technique , either h}vo oF Siw. - Key pebounce aving harduewte + OF Key pasition | a |b | y ce | 7 a e fo fi tL] belo a I ! oO oso" yet So woan am fel wo YL elt Yell ha — TE consirts of Flip ~ Flo - ~ Logic 1 when key & position A Cunpressed). ~ bogie Dn wn vB Chey pond 89 OP las ny * Output aloes'not change dusting transition period » elininaty, ker de buncing . ' : + BV O70 AP pore ‘ing pres watts for atleast ip ms = Cae the | nice proceysor / mifomconte! before “ik accepts the kexy as an ip. 10 ms period % Supfictent to settte Rey oF steady, fe When a x, “4 FR: Plowochenrt of kay T]p ustth debounce. : Aq or Key debounce Cio ms) Read key eel +5V Simple Keyboout 3 snk exfocn Fg: Siraple Kkeyboorel Tntemface — Fight ke ane YwelViduartly connected port P). 1 = Foch pot pin Gve ane States of Key connected te reat PE — Whoa post pin 1 bogie ty Fey B open, Orertie we % Sixteon keys axe arranged in "ows and Columns sk When Ox OPEN, re arel column ole net have ony Connections . ° % When Qny Keys i pretted Te shorés Ceres poneling ona WH and one colurnn. 5 TE vequves two ports : 9 Hp port and 3) olp op pot ‘Input port > Connected to rows Cxefouel to ae) / Output port —>connected te column Crefewad to xan) Wf te output Hine Of the column & tow,1e makes recl! othetoke tte Status Cf row Une high ofp. port a, pata Sent - jp pork > Rocetved Pcp interfacing : - at recing cuxvent +, TL mefers to the maximum cuerenk 4 R05) pox Pin can Supply to dive an externally Connected dai . ¥ TTL forily of Bos) devices the Sourrcing current ts bo MA- inking cuemenk > gk refew to the maximum cworent # O51 Port Pin can alesorb terough a device which Bs connector + to an external Supply # Pins of pr,Pz ard Pa aan sinka maximum cwerent of oma, * Port O pins con sink Cuscient apto 3-2mA. Vee =e 4 fF wie? Pro pT ;Zosr | vss L = py LED connected in f Curtent Str mec LED } } Ra Peo MLL fo) LED interface Zn curert Source mete Cl) LED Enkerfaca tm uurint tink made 1 at Vout — Vi pe Neca Vien foo eee pe (Tito / BD where , Vieo is the voltage acrnss LEO Tiep is the cwoant treugh ae Vout th tha Voltage ak oukpuk pir B & the wwumnk gir Program ; ORG, vop0H Bra. SETB Poo , Acne delay CLR P20 Acai Delay STmp BAdk 3 > ; Ss Multiplexed Te Segment Sipiay 2eetfocing : Fig ib “ Seven Seqment cis = ae i eqment clisplags axe geranatty wed as umertead inelicat # Consists of a number of Levs crerangecl in Seven - Seger? % Any qumben blo o and 9 can be Gndtzated) by lighting * Seven Segments are abetted a to gand dot & tabelledas } * by od Basing diffrent Lep Seqyrents. 0 Baugh oe Two typed : t+) | D Common anode tupe 2 Coromen Cathode cyPe ° Cap Ele Gi cle type Cb) Common cathode type Cay Common ano: Fig: Tntenal diagno of T-segment LED + BV pteractng Le Pisplays: ae lA cP lB 7 calculated : Rips le 4 Vee —AYOP across Jen Segment aT —IR=0 Spe PYOP ACYSS LED sepmonk B 1. y Fig. creat for deiving Single a T Segment Lep display o+ TR=Vee - 1 Sy = 5-(-5v-3.5 ‘Fach LED Segment‘ nequtves ‘a cwbient of betooeon 5S ard 3omA. Jet casume . ewnienk through LED Segment is. 15 mA, Be 5V “7 Re = piqua iSmA 732 —O T=¢ Coligh >) x7 Csegment’) x ISA euxrent per) — gio mA. Segment Led Takengacing | fe onan iB Bin Seu is [Desckption Choackers as wellax numbers, z Veo = ey ane avaiable t Ibx2,20%1, rasp POx2,20xH and Hox sizes. 4 | * The module has My pins. 5 eae ere ee | iecete ecearseeee TY |PB- 287 |T]O nter nat, \ “eye Gen, 1 Hg: untelyacing Leo module uth 40S) , ™ 805) i 2) Pro anarning Embeololeal Systems mer o embedded @ prograranting language, usee the: Same Syntax and Semantics . ’ G Progprarornting fanguage Like motn fiostion eon atid Hata types defining Varicioles , Lops , functions , aterterrent ye, Featurres, of gmbeclded ¢ : % Only the extension of C language ' * Souter code formeut- that depenols upon MC oF mp. ® C High tevep optinfization . : | % Used ih . roforopmcstor os aifer controler applications. +. Embeololed| system hove only memory focation . * Only Supporls the adequate Procetsow ox Controller 4 Embedded c ently pre- define progam con wun. FQ dightat cameras Dvo and cigitat 7 #& Con ng, Speed and size & very Simple lceyuersd i embedded ¢: 28 A keyworsk i a Special vovd with a Special meaning to Re tomptlex. keyoorels : BYE. Shih, Sfx, smell Loge fpate types tn ernbedtoled ct Data types yO Signed ink wnsignad int signed chor Unsigned chor fio double ete-, Few move clata types th embeded c, ! Keil’s Cx 1 conapilen arte LiL, SbIL, SPrsSfoIb . * Vorioble is an addserseblo storage location . tne XOYZ5 chest a, b 5 2 Ete RAM etc ¥ space for voxiables may be allocated in veginters, ° Nartfale Arey’ : ; , An array "is a Sek of olata, Stosed in consecutive memory codons, begenning ot a named) aclelxeys . Seclure aioy : fanct No. of data elomanrts N- Elements ase “Ft pice h atte Bifferxence bebvoean Cc language and Embesteleal c : S-No| C language Embedioled c S ‘+ 1: ' Genezal - purpose Programming | extension of lanquog . oe @ Desktop~ based applications, |micvo conbvol [esi bese ol 3. |Hovrel uci “inole penclent. pplication, . Hovrctovre elepenclent 4 |Standasxcl Compilers to compile Generobe. particular land execute +0 ae hwo 5 Readability modifh cation: Reackbil?ty modifeecton ss Bug, fixing Gan Nery easy - Bug fing cue Very Seay. 3 |Neod, bow ee Suns a Alffornce betwen arc and Sof Real Tire Syteng + Real rime og ° * Qualities of Good RTS % Choviectoristica of RTDS %& Hevo to choose RIS. Sefitition : A Real-Time Operating system CRTos) tan operating . ‘intended to Sewe steal -ime, applfecrtifon process clewbe af i. Comes 1), typically udtRoeet buf fertin, clelays . Aepencls on both the functicnal comectnoss and He Eiraing Coprectness Riper of BS: RTOS ¢ Hard Real Hime Soft yea! timo ood Reed time = # Ciitical task & ‘completed within the time Limit. # Boer not Suppost genwral pwipose operedting system. Cannot jeep vookittiny for Aonger fteme witRouk cldnabi Cannot guesentee tok it will be able to meek cleaclline undex cul condition. Eccoumple ; Aigital Gelephone ane] i qital auclio. po ie reat iene Spplicedtons : : Ss bTranspowtedion + Avr Excp fic contact and Leeeffic. light Sister. 2)Communtecctfon ; Algited tetephone 3) Process Contwl s petroleum ane Paper mul) ty Betection : Bureglor gyrstem and Hacer Sytem . 5) Flight Simulation : Auto pilot shuttle mission Simurlakoy, Ipifference bebuoeen Hard and Soft Real Ane Syktem S-No| __Havicl_ Real time | Soft realtime Hard wwsponse dime Bs equiredd.|sofl seaponse imo o> steqputee cl a. [Bate tntegiity & short term. | oka integrity c& Long term. 3 eee data $e B smut or stm “A toorge. Ae [Peak Load perfosrnance as peadc load) perfor mance peedickeuble, B depraclad Safety ciktceod Systems are Rg typreotty hod xeat time Slr. | A realtime Kernel 2s softuaxe tha rmaneugos the tme ane) MercuAced of a micyoprocebsoy, micsocontrwllen and Provicled fnelipersoble sexvicea . Real time O08 Computer eielurcre Fig 7 RTOS RTOS Kkexnel Serviced -- Applicocttons + iy Timers 2) Hevice. 1/0 Supervisor. ited ony Bleck. C, ei 3 Aynamic menor auccation AY Tok monagenun ¢ 5) Tnlottark Communication ancl Synchwortization Me cove of an IDS i Knouon ab Hie kernel. : A thrwad Bb dike a function ‘thot hes ts ovon Stack ener FTyPed of Timers : Times Period?c times Apentodlitc timers Reticdic simer : Once o periodic Hime i sok, exch Hme after it expires 4 [Cosespending haneller soutine fy fnvoked it gels sremnsertted into tha time queue. Apericclic Timers + Sa Aperiodic. Timea aye Sek to expbe only once - EQ: Watchdog timo . Kernel Applications : D Tess fi ae > Concurrent and independent throacls of execution %) eae —> Token - inesementedl on decuerent . Rage quads _s, Buber Le r 5 a Good Rros: for Meissarcher? ae D Performances, past 2) Reliablitty —s. RTOS shoulcl not fort. 2p Compactnyg—s, seatte os tuna by Scalability —> octet rere « Ane 2 Jor deleting moctutest Compontnb- chor acter sites of Ros: om Beteiminigm : Operations are perfoymed at fred. Responsiveness . user Control Reliability Fall soft operation Hoe te cheese RIOS + Functional Requtvements . ( Precessor Support, rly veq. Kern Tpe) 2 Non- furctionap Requivement .C coe , Ease to we) functioned Requtvements : > PIrcesSo¥ Suppovt : All RTOS & nok support +o ati Kinds op faeces fO Memory ~requtvement : ROM Steves oS files. Non -Noletile moly tke fash. > Kes nel and Tnkecupt lakency. ¢ 0 may disable intectups ) Ms) “LPc and tadk Syechsoni zation . 5S Suppose for Hetuosking and Communication . Non - firetfonal nequiyements - U7custor developed on off the shelf : Bepending on #2 0% Henutfewenls Suiting the embedded Meads DCOSE > THES Get must be evatioked before faking cedsfon , 13) Eade to use - ee UU , we S A) IMurgple, “Toss And presses waste “JOKES OK # Inbwduction %* mulivate cysterns shal and achedaltng H prods § oy schedultna, pobre’ rteeduction + \ : % Taaks axe wib of sequential code implementing the Sys, actond ond executed concwrren ly Be oe ae # QR Ta abe caved a tovead . x ath Task is assigned a prior by 5 | Process > we A process ib a Sequential prgrere th execertion: | & Terms Like Job and tayk are alo usta) to denote a pray { i a | | Uneomnpressed| chariactert | data | i} | | Tb owon Sek of Cpo | | | | “Fig: shows an on- te ~ fly compression ba | deput and cutpuk of the mprevtor bx ts seitat pore # DW takes uncomprrred data ond pevesse? ‘it. % Culput of 4f2 ox ws Compressed clecta Hulitrate Systema’ + - #1t have multiple Sensore and actuate ¢ # TL includes automobile engines s pRNLELA cand COLL ph ene . TJosKs Sychworous ASynchvonous Qyrchwreus LAK yoy mecut al ciffewert scutes , Eq: Peso 0 # Spark plug must be fred at a Coren point in te Combustion cycle. VE orptiee # Tfa phase reledionshtp blo to Piston Mmoement and the Spork. ¥ Automobile engine controitens use adlalitione | * e NY a Senders , including tho Jes pedat position and an Fig, agine Gober kruger Senos. Paws Sete and scheeluling ; Foch press hak an execettfon stale loRich Tnrelfccdes what Prcesd Ds curerentey oloing - Csenke Bull context / . neque PE oo pee C ) ‘ cs SO Schaller gee ‘ bo, Te press strter ao as follcucs : , ¥ DNL arrencty 3) runni'ng byicaiting and Enef. | NEWS creates neo process by ewtng fork © System cn, | Ready rhe proces & Completing for te pv. Cqueue y Running > tho process that os cwuntty being executed vaaitting ~> A procets ts voodting ttl Some event - 1 EL 5s A preets B complees 7 eperations - Kchedulh licked + cee aes B time for process te be sremovecl fiom the rs Ped which ready process Shoukt be allocated the Cpu Merb. CPO Sheduttng | Peemptive Shadtulting (Pesompve Scheclulfing : A Schedlulting Methoct that ‘intevuyots the Preceising of 0 pra lund transfers the Cpu to anothent process. TFi2 preass suofiches from Stunning Slate to the yeady Sak Jared toniting Stab ty to Yeacley Slab . Non - Non eve Scheatulfng : Non ~ preemptive scheduling TE proceecls towels Completion unintevuepled. One He System has assigned & procllor ty ov proex. He (Fa sunten Cannck semove tre procertoy from the pra 3¢ Switches frorn muunning Stake to tho waiting state and eae of procors. ys etna: eH B)|Context suxiching + |, Context susttching db. the Sustching of Cpe frorn ond Pecos fo anothrey procs. Ie The prewss of Storing tho Stak of OX process , trwacl oy fpocomer operating rode . All POW are running Simultaneously. pontext suitching tiggens axe ; SA D Intevr ee We xequive context suitehing ¥ Pase Zs an CPO t ddk. ay Nuttftasxtray + - *6 the Cpo hes to move Precersea in cand! out of roy. Tt can AUN yore than one OPperection . > kemnel fuse Sutéch + intewupbion of Tf we nequtre suttching bleo the wrex mocte to ketned. fouewing actiittes + - a eS . c » Suspencling tho progottion of ore process and Storing the opu stake 2) Rekmeving tha context of Hho noxk proce’ fore mernisy and restoring a) Returning, be fa Jocatton rnclzabes) by Pe PC tn order Co rostrme Ha process | D Softranre content Suttehing > All Cpts ancl can be ted te gave and ruled D Yoteloare context Surichirg: 7 Save fe existe “CPO Stake cod tckex fo t nD cpp stake fem{Tavic Stak Segrent Po > cag Kee, Rxlority Bare Schecluling policies +) MES DEaalfext - peadlive - Fest Scheduling + CEOF) Exp ba Preemptive scheduling algotiirn thal olispatchos he proass etth Ure easnttese doacttine ap an asvtiving Procoys Jras an eorlir cleaclline Han He va Precess, tho Aystem proempls the suinning precers andl climate, Ite covtiving process . Scheoltatable : TTR tars Can be guarantead to complet ttt executions | [rei deadlines . cp thoy can, then we Say Ha task Sek sly Conditions Tolat uttlizedtion of Re task Seb must be Leys Han o; equedt to I. + i I (wo o 24% Se Pe ge eS t i | T | 1 i Zod + 63 EDF pxoperticn + ae ? EDF ie optimed with suspect bo fecsibiltty se EDE i> optimal with respect to minimizing the maxinrum laencsy paseo # Tk % optimal algorithm # Perticdic aperiodic and Spowadic tanks we echoctiulod 3 Gives pest Cpv utiilizcition. Sisacvantages s ¥ Needs pviovity queue * Neos dynamic priorities K No OS Support F Wiffreutk to implement fete Ugneteniie scheduling ; % Called a& Statice pYiovity mound Aebth Scheduling algatitirn * pionty 3h ineveanes with the ue at wRich & prasd mut be Scheclulect . % The process af Lees pertool uxt qat the highest pro ty . Fach pertiect&c task & assigned « danny tu » Te Shostey the peitod, the higshen the priovity : , 2 tra Longer *he pestoot, te Lewoe n pea 1) Simpu te undcleertaned 2 Beau to ierplment % Gabe algorthro Gio aa Saar Fe ee att te s by palevity Town :- ‘ % OCCUXS cohon a tov —persby Job executes fEle Som Yea, highot ptertty Job ceafls. Wc Bloted ET) Nowmal Execution BS co to €3 th te Le 47 49 Time to ky % Consiclet tree asks Ti,T2 and Ta with decreasing prog, # TOK T) ancl Ta Shar Some data F Ta aloes nok interact wfih efter of to, tases. pHostly inversion Ti =e = J2-W_—____ See 33 Se } Fig: peovihy TNVEsIOn exompP& Wait fox. graph: OO) 3S) en @® Fi ig + Wott crap} 5 dynomic permet a for corr At any Hime, the cate fev giaph contaiea an eolge ft liom Q SWhSUTEL vertex +to a Bb- Acyclic pot, th a Loa t - for graph indoles daccbles Tz hay Locdeed Hy Singty anit Rane < G edhy- Ua ~ Tr aehee| i

You might also like