0% found this document useful (0 votes)
80 views38 pages

Unit 1

The document discusses embedded systems, focusing on microcontrollers, specifically the 8051 microcontroller architecture and its components. It covers the functionality of various registers, memory types, and addressing modes, as well as the role of the CPU in executing instructions. Additionally, it highlights the pin configuration and multifunctionality of the 8051 microcontroller's ports.

Uploaded by

yasminbrands
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
80 views38 pages

Unit 1

The document discusses embedded systems, focusing on microcontrollers, specifically the 8051 microcontroller architecture and its components. It covers the functionality of various registers, memory types, and addressing modes, as well as the role of the CPU in executing instructions. Additionally, it highlights the pin configuration and multifunctionality of the 8051 microcontroller's ports.

Uploaded by

yasminbrands
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 38
uniT-)_ EMBEDDED SYSTEMS AND Tor @O d sygtem : mbecldled system Ba system that combines oftuoarre to perform a Specific tase. YE Based on either a mc anda mp. Jembectole ¥ An el quote and Si Escample « TV neod to Conteol tho TV, need this semote. To get inputs prom users and Changer the Tv chanpels, This Hemote to contso) just tho TV, and not to an embedclec! system. I contyo) an Ac. This og bit Mfoxoconteoll Ceo5l: cynopsis f * Tnbseduction 3 Microcontroller H see oN. =aee es1erice bebwean crv PYOCESSOS and micsoconbolies __-# #i6g = Feo tirses (oF 2051 microconbrolles- | Lneeidltiction = ~ TEL lesignedl by Tntel 1981- nt eg tirae i as gbte claker GE OTE - eX TE has an @ bit processor.” Tk hoa @ bit data bur and 3 Tt hola HKB RoM) with 12g bybes RAM. ye Used to execute artithmetc anol togicat openaction| ye Focamples + 803), 805! - @ bit me. 1 Microcontyrile¥ = Tt B stefervied (© as " Computer on - chip integrated wth manu components ee hime, clecoclex, Cbv, RAM, ROM, Inpuk -cuteH p ombectolec! Pnside TE - lo brtt actelsexs bus, A-ceip, TEA & Ke memory » t poste fand counters along with the ch? Te B called as mitcwconbrler. oe MCN + Veny many Prerny . Max. © > May; lan A Micreprece ccoy can just process the forme ‘ } 5,8 ix Information can he ctoreof twing ROM. Rang ay | Communication iMlerface Peripherals , timers And rp Yo can a be adnled externatiy ty Suit to Psrfeot Noel, u , Torey ce beter MID pYCeSSO¥ anol MerDcont re THe, A-CHip i | i 2: lhece Numbes of register Move number of Heqistor, | Rect, | {3 eure i Complex — Lege Complex i 4 EE have zeyp Status Poean’t have zero Status fag hq 5 [Mernony ane Tle Compenent emery cid Tio componeyts mE connected extevoatly Axe Connected} interaiy | | | | | i | [7 Tt bas man natructoud Te hes ono or tuo Fnxbarc tio | | | 6. ( hos Single miy Map |TE has Seperate my Map. | | } i | | I Move olate to move dala. 8 | Les. Number ef pins Move number of pins Move flexible 1 PY | tess flexible J Features of Bost micrecontrollesy +. lata é #uUKB ON-CHIP Rom * Extoinal nly -bukR : ¥ 128 bytes Ram * Serie) data tx and RX It consists of a Cpu. > Two Kfnels of memory gections D Date. Memory ~ RAM 2) program memory - EPROM ]Rom, Tle posts , Regéters —> these elernerrts Communicate, Borough an etqht bre clate bua - Fig: Block dfeeprom of SOO) Se caste counkeY nkerouppts jnpats INTO NTI na Tnterviupe contro} =| es vent estat ah i “" R>p ie Ek byte 30 Bat ehh Limational bento) processing Unte: J ~® L bit cofitimetic. and bogetc unit, ¥CPV consists of elg r agisters Ike A,B, in sEcpu casoctated stegisterca ve A ae a ea ; progam countey and Dela pointer. SP -Stoeb py PSD — ten gin 4 3 Stay, * ALU: it > ALL consials of one biL ar well ad & bil. Ik performs avtitimetic and dogécett operations . IEnkexvupt contol: * Stgnal emitted by a device / hiv o* Slew. ¥ Terminates a cwownt process J # SoS! previdea 5 Inkeviupt Sources DINTO ayant; 5) Ri/T 2) TFO AY TF) #Mbercupl Bc Sulo-voutine call tak Ibecwupt of rm, # Operations causes to erecutte a Sub wouttne. Psctilators : ¥* Tt i an electronic pulse generation create. # Te provides the pule signod to tha cpu to complete Fs Open | # TE has no on-chip exystal oscilatey with prequerey af mi uS Contryo)| + Two typed of Bust n Addvess Bus and 2) Dato bus H AdAKESS Bus: TL how 1b BIE adebasd fox Exansfering He aati | # Data Bud .tt hos & bit ackcurs tronsfertng ee cob, Bus conten! Signals are psen, EA ane ALE. i PSEN > Program Store Enable ALE DAdllvess Latch Enccble EA—> External Access y ia and B CPO register: Regi stes A: Caccumulator ) ae It Ban & bié negtster. x TE hotels source operand ancl srecorver tha stesclk ©. cotit herr, anstwucttons - * Functionds = » Rotate 2 partiey computation By Testing fos Zee. Register Bt ce & used for He bluo roulttply [otividle operatton le BIL DETR : DPH DPL fs me rey ——— add SH SLE " ie Ipata Pointer : % DETR consists of high byte-> DPH Low byte > DPL yeTt consdls of Ib bik acdleess - ye Two ‘independent @- bit regbsters % DPTR doed not have & single {nterne! acceler - DpH anc DPL have sepaviecte gntercnak acicli essed. program Counte’ ; 4 Tt has a lb brt progr counter. 4 TE By usec to hola the octelvers of rly tection from tohich the next Instruction i to be fetched . Bos) Flag Bib and the psw Register : # PSw —> Program status wove % psu Lo alts Known as fleg, register. 87 Be Bs 6 Ba Bo 6 8 cy [ac [Fo [es [eso] [= LP] y T - 7 Xv Y v 2 AYonys 0 yen {ow w YL: Cooviy Flag « ty i a An overflow cuk of sib 7. ©: # Corry fing alto sever ad a boreto flog fox Suber # An overt Plow ouk of bE 3 + Casiy fiom lower pibble to hitgrhess nibble Cp. FO = Avatiable for wer for general purpose. Rst = Rso = They seleck the working veqisten bank oy fet, 3 ty Ds, m Rsi Rsp — BankSelection i. © ooH -oTH] Bank © ' OGH -OFH Bank | i tOH ~\TH Bank 2 ° ° ! Y 12H - FH Bank % Le low Flag + leone Ths flag, 2 Sek whenever tha Sesutt 6f & Signed punrber Se causing the Wigh -ovder bit te everfleu tte the sign by pate eeg: Polity i defined Ly tre no-af. ones present % accumula P=0,%f number of oned aro eyen. Pel > 4 number of ones are odel. Some avtithmetic operations urhiich Prvolves Cosy ov bessou os Change “thre. ‘Program ‘conbsol wwstng Gnditfonal branchtng. Spectaf Functton Register of OSI (KH . fie qpoup of registers implemented to perfor? Special functions and aw locatect tramediately, above he ; Ing bytes of RAM cw Cettlecl Specter) Feurction Peg | n Above 1oe byte of RAM. yee + Heorclooosce. wen byte addyess BY Laddvexs Sypmbe ket QD pOMSB OFFH CLSR) oro N eB cegistet \ \ Bieoy ‘ \ yi OE DH Ey [EG | Es [Ey [Ea |e2 |e, Eo| ec) aecurmlater oove cove opener Pe |e Pa |e bol rrograrn Stabs werd > 4 [a [2], [Do /Ps| prog ! | one =|- [= [e<[eefan Pq[@e| cp | tn ewoupe priory contort | | + 7 OBoH| By Se [BS |8y es [82 [a leo] Pa / pore a | lee! | OARH IAF] — | — [Aclpplaalra[ra lize) Treeompt Enebee cert, OADHATIAL | As | Ay [Aa ela, Bol/P2 pert. | i i 988 GF Ise] 9D re ae a fea 98 lccon) — Sevial contol i a i oH jorae [95 | t4 [43 [92 [a1] 90 p\y per necle | Seh lerlec | en] Sc]seaeaq}es|tcon —timer/ counter W™ | pal oF 80H la] eb /E5| su] e529] 9) 8q\Po 6 pore o Fig: SFR Lie addluwsd Con [rol ) FH Cpocwer Cor ; rk Registers between ZOH and F | } pot? aust ost sg > Pin Descviption of 8051+ ® 3 2051 ks packaged th a hio-ptng. a» Many pins of ROB) ae used fort moxe than one furrction * Evight -bit povictiel porls ( po,Pl,P2 and P3) . AI four ports ate bietivectional. Eveopt tho pie of por, Our? SUPT ! on) Vee + BV FB 3a | [P00 Chingy 2) z 38 Poi (any 4 31|}-——~]po.2, Cana) e 3b Po-3 CAb3y Porky Gb 35 }-——|P0-4 (AP) 7 3uf/——P0-5 ¢)| § 33 |-——_|Po-b (Aon) q 32. | _—P= 07 [P3-0_ CRxDD lo S05! 3 | — ener) P3.1 (TxD) ” 2 30|-___ ALE ( prot}; pea ere 2 CHo pin) oa i J P33 CINT! ha ‘ ;-—— pSEN, Poa | CR ie Oe = Poa CAs) P35 (7) |} —__|15, puat go-lin® a \Po-6 CAM) P36 (mR) be e [———P2-5 (Ara) ny 26 E ie Pa CRB) q Pe Poh (An)| Pi [_eTAL eal Po.3 0 An) Ss. xa A 23 Pa.2 ( Ale) > o 22} |p.) (Aq) coy ia at |pa.0 (ae) verre stort for “J poral osenotm ~ Es a Fig: pin-out of 8051 pe Post 0: (pins 32234); Sjusea as oe ple. > Acard external my, .C low ovelet by&) > Use as only 5/0 pins ~28) > Acard extomal mly, port 3: (pins toyz). Ib Bb ackliors Chigh order byk) > mull functional an bo > Wo external intercuyphs , bco Counts WP, Specie data tines. Post 3 ( prns | @) ‘ Port 2: (pray 2) ee ee Ppatention Sb ont Prager ning @ opics : G05) Adelxessing Nocles Q classification of Tnstmaction Sek of gos) _ fata Transfert Tnastauckons _ Byte level logical Tyabauct on _- Asitfimetic Tnybmuctions we Bit level tegécod Tatu ckions Rotate and Swap mnsbructions ssump and CALL ans bucttons 4) qime pelay of 8051: O\god! Addvessing modes + gynopsis + ye Befinttion x TYPES of adelxessing mocler - Db Register adetresding 2) Miweck Byte actelnessing 3 Req ister Tneliveck addrersing . 4) Trmecttate Adelvesstng , 5D Register Spectfic , we | 6) Index , | Fo Stack axcielswex Si ng mecte. \ofenttion ~ The data Souvees 077 destination adders ee Speci fied In tre trateuctton mnemonte. for moving tha dota is cated ‘oddeessing mode ‘ [Types of asldywrsing moder : # Reg fater addtwersing, a 3 Bo51 can acces & “wosk’ eg’stexs”(RO-R1) { # Select a sregisten bark by moolt fying bits and BIR a vesunation pee og oN Progvam ; oe Mov Psw, # DooDI000 Mov A,R3 | ADD A> Ry | Stvect Byte Addvessing « B > Bank 26 Selocte, 4 # Access any On-chip Voviiclble.C RAM os Rom) * Most Signifrcant bye of the adders deciel ©’ Ray (tg ¥ Special function Register w® MSB =). ty memory Destination Regiatert : . Adeluens of me Pe witht the at Selected Program: Ieeatio MOV A, BDH 5 load byle fromm adelws 50H into 9 PED ALG . ot ae Contents of Aand Re contents al nh locatvon 51W- Register thelfreck Adebessing : * Ro,Ry can be used an pointer vegéster, #¥ Indirect cae wes te '@ sign amor. Program : MoV A, @RO 5 toad pestination App A,@Ri sA00 Reiter Data ern | red cotcted A gg - r Mipeaton “of fm meclfecte Addressing : e el 3: > * Source Opertand ust be a constant Ci ¥ "HE Sign is used. ata freoqpiate z mov A, H= 52 = 4 * Spect fied Stes ae Reg" pecific ? tm the enabmuetion Refer tra Specific rreqister Such cus accumulator os DpTR, Preqram : SWAP A 5 Swap nibbles within the Accurmuator, tindlex + Fithot the DpTR ov pec can be used as an index Regitey- DPTR_Registert Pp am ye memosy A Reiter aoe contents of _ DpTR register a ane, era 5 Selected nemo) meron pare: | Movc A@A+ | Contents of sicgister A DPR Stack Adctessing Modcle : sacttons C push ancl pop? ve usec. ye Stack Trt # *pusnA’ b> invalid > Specify the acter of rogebter A. sk PUSH DEOH ds a valid Tastycti on : # Rais sacs the contents of accuroulator’ on the Stack. Pieogprare « PosH Oh Push o& pop o2 pop ofoH —L , 2 Ploasification of gnatwction Set’ of 805/:- Synopsts * 2¢ Instruction Set x Classification of Inatwctfon Set » Bato transfer Trstruction. : —TnStauctions to Access External. Datel memoy ~ Inskwuetfons to Acces external ROM/ Program py ~ Data Transfer with stack CpuSH ancl POP) rn. — Data Exchange Tnatuctions. ® Byte Level Logica) Instructions By Bit level Logical Tnatvucttons hy Avithmetic Instructions - Tnexementing and Decvementing — Addition — Subtraction ~ Nultipiicatfon and xivisfon — Aecimal Astithmetic. 5) Jump ancl CALL trstructions ° ~ Jump and can proyiam Range = Jump — CALL and subsoutings. Instruction Set :- : dn insbuction & o Single openaition of a. processes cleféred by an instruction set avtchitectitre. Sata Trans for Tratuction -- 0) # Used th Move Tnatuctfons , Mov , - Bytes: 1/2/3 cycles : 1/2. e / Mev A,Rn Mov A,Ro F ‘ S Mov A , dicect Mov A, 30H mov AsOFI Mov A,@Ry pov A> dala Mov A, #EH3N Mov rn A Mov R2,A Nov Rn clisect Mov Ri, HoH Mov Rn, H#elata Mov Ris #23H Mov oliveck eR Mov 20H ,@R3 mov divect Haka = Mov 30H, ##20H Lrstuctfonds to Access External Sata memory : #MoVx L used to RAM] Flo. etyod # QF bytes adcbors # GHikb bytes DPTR adlclueys Movx A.@RF mMovx A,@Ro mMovx A,@DPTR DPTR to A movx @RI, A — Movx@ RIA Movx @ppTR,A A to tb bit in PTR. Iinstwuctions to Acc» External Rom | Pro} MovCA,@A+DpTR Adding A and the OpTR sto A move A,@ A+ Pc Adding A and the pc ,to A- Joata transfer with Stack Cpust | pop) inateuction® + PUSH otisect : push onto Skack gram memory). Bytes 22 cycles 22 Eg PES P Pop cliveck ; pop fiom stack Bytes 22 cycled 2 Eg: Pop ACC. — Data Exchange nstructfons :- ¥ GOS! executes MOV> PUSH oF POP Trdtruiction. sé Taked place the ‘Copy dpenation : Bala from Re Sourwen arcldrews ts Copied Ay lest x Exchange Insinictions move clata fromm Source fo dan cclelsiess and Wiee Yousa. Al) exchange involve ta ave i t XCH A,Rn XxcH A.Ro XCH A, dliveck —XCH A,20H- Byke level Loyiaal Instructions + (2) The inatvuctions axe useful for DANL » cleaving 2 ORL 5 Setting 3) XRL > complemernting . Logical functions - "AND, 0, EX-OR.—> 00 byte, Vostio sien No flags cow affected. AND operation : = (age) xXXX" XKXX ——S unknown ge bit birauy Hl} eceoo _y, Maaskting pattem xx xx OC000 Roselle eee Marked bits OR _openation ; —y, (45 xX xXx x xXXXN ta I OreiCae Setting pattem VoOXXXX __. paste kek bits Fe opens whine UD xxx xxx 000 2 iis 08 Fe Patton . " RXXX RRS eon foc inverting lower : Tnvernbeck b? bs ANL 4 dest — byte > . 2 sve — bytes >: Logical 7 AND a Byte> : YVo/3 cyared = V2 A PR Zand Ro Ste ANL A,Rn @ANL A, 20-4 Ce ae ANL clsectk> A ey ANL 2015 A A My lechen Ber | | loRL 4 clest -byte >, < Sve ~ byk> = | fcal + OR Byte> 21/2)3 | eucle® * V2 ORL A, Rn eg: ORL A>R2 R2 Sines HA . veut XS . oRLA,@RI eg: ORL As@ Roe Steven fo a dato Vroly locaton eee 3: ORL A, FFB2H VY 324) Stoves En A RL £ dest - byte >, Z sxe - byte >t Logicok 2 Exclusive -OR f Byler = 4/213 cycles = Yo XRL A, Rn eg: XFL AsRo, 2 ABR store or KRL A,diect eg: xRL A» 208 Location XRL A,@RP eq: ARE A,@R2 2 sive Lie p:clean Accuralater: ce) Logically complemented - 7 No faye ov affected - ~> Accanulatos ts cleaned Cali vb? Set on 20) i ! Bit level Loge Instn # Sel ow Reset a part SFRs. se RAM addlvess 20H tRyt0t 4 Bul, bybe and bi ctions $C 3) is b Fculay bit in the internal Ram on Byte _Addvess in NOX pit Addoussr th Nex eo 00-07 2! 02 —0F | aa lo-)7 i ee * _ | poe al 28-2E 2b Jo: ye? ae : Ho-H4 ; ah 2FH (Both LiL, Rye tadcluors Ce different . rr Bit and Byte adclrers, of SFRs BIL actress | CLR C .Clean Caxty Flag. Bytes ol cycles all CLR bit « Cleat cliveck Bik Byten <1 Ciycles ea SETB cz Sek cowry flag Bytes 1 cycled: ISETB bit : Set disect bre Bytes 2 eyctes s ANL C, Z2Sec-%5it 7: Aro Byles os cycles 2. ANL C, bit eg: ANL ©, Acc] en cory ORL C, dgwc_bik>: OR Byles 12s cycles 2. MoV s Move bit data. Bytes eae cycies © A Movie, bit eq. omy C, P3.g carr? I ORL ¢, bE. eg: ORL c, AEC Cy With FOE Arithmetic Tsdvuctions +O) ‘on 8051 fnciude Increment, cdecvemenl . adelitioy, Suh bye Fey, multiplication . clivision and decimal operations. y ILncrementing and pene a te ¥ Allow addition and Sulbeacton of | from a given rung ® Tnatmictions not affeck ¢, AC and ov flags. my INC < byte > : Inceement Bytes + 1/a cycles : I/2 Inc A Tnevement Acernulatos by) Bytes Cyetey Tne Rn Tnevement Regtstern Bute ) Cycle) Eq: Ine Ro. Po »y) INc OPTR | thevement pata enter by Byley a DEC < byte > : Decrement Bytes so cyctes | bec A [Decrement Accumulator ey ye 1 cys ley DEC Rn | Decyement Register. Byle! cycle) Fg: DEC Ry: Ra byt DEC dlivect Decrement alivect byl Byte 2 cycle | Eg: Dec Don - Adoltifon : a ws by) ADD A, = Aclel Bytes EVES Cycles a ABD A,Rn |Add negisten to pccumulator Byb i ost Fg: apd A,R2 Jadd A and Ro, Store to A ALD A, cliseck| Add direct byte to Accumulator siy!2 HH €9: Avo. A, 20H Add A,tedatal Add immediate cata to Accumulator £9. ADD A, He20H eget » apoc A, < Sse byte > = Adel with caviy @) Bytes . 1/2 cycled +1 ADE A, Rn pope A> dliseck avoc Art data App A, @R? Lyperactfon = guae A> <8%e~ bye >: Cubksack with Bossow Bytes +2 cy st 6uBB A>Rn SvuBB A, : SuBB AL déxect | Suga A, 20H Byte 2| cycle! yaa AGRE suse A,@e2 | ayter | cycle | cupp A> traata euaaAs HOON) By 2] ‘cyclers 9 Muttiplication ancl Diviston : ; MuL AB* Multiply Bytes =) cycles 24 > NvL AB mutiiplies ths unsigned . —> low order byte of to Ib bie Clefe accumulates ) > High oxdet byte w B. > if product i guatu an 255 CEFH) > Flag & set ; £9: 8 C5eH). Ctorvtse Cleans MuL AB 12 oo 3200 1) BS 32H(0elloolo’ > DIV AB : Divide Bytes 21 cycled +) —> unsigned > Recetves the integer poxt of quotient > B veceived the “integer semainden i > cosy ov fiags wilt be Cera’. Fg: 250 (oF BH IH L010B> SH Di AR \Sectmab Arithmetic :- for addition DA A: Decimal - acdjuse Accumulator Bytes +1 Cycles +t > Must the 2 Bie valu from addition of tw0 vortiables - > prsluce Bep vesult w th the accumulatys ‘Sess Eg: A=55n Bx=b&H CFz} Tratruction Sequence AbDC. A,R3 DAA Jump and Cot! drstructions : Jump and CALL instatctions change the loco of He prepan by changing the contents of Progam Counter - ’ > Jump permanentty changes tha program flow. > CALL tempoxaxtly changes flow to ator another port of the Progra to tun. > Jump ‘inatauctions uskich change te pega flow if Certain Cond?tion extsts. F9: CINE (compare and Sump tf not aque?) (&) Types of Snsteuctfons charge tho pogtam flow. Surnp on bit Conctitions . A) Compare byte and Jump iP not equal. 3) Becvwvent byte and {ump y Zeto- *) Jump unconditionally, 3B can a Suesutine & Retwin fiom a Subroutine. Ss asmP adds! | pvselute Jump Pp adds Ib] Long Jump Byted 2 | Cycles2 2 | Bybes +3 eycles 2 Swap nibble usthin accurmater A->23 000 001) GaP -7 32. coll colo Lom: sme vel Shoxt Jump Bybes 2 cycles 22 inelisect iM, At OPTR |yump nm . Io! Pe yetntive to the Bytes 2) Cycles 22 DpTR ie xe Turmp tf cry Bytes 12 | Cyctes 2 | frag & Seb rotate and Swap Tnatructions + Bi cles RL A Rotate Accumulotos heft aa { A> tiog golo Jy RL> (SSSSVE\ ec A Rotate Left through comry fq © 1 peo o0lf ( { RLCO Lick A DK 10 2 °F TO riers eetee] | | RR A Rotate accumulates peg te { i | 10.Q2 (Q1L0 | ieeae SB | | RRC Smo fecae f eae| | looo lol I c ca | | | | | tloe | | | SwoAP A : | | | pod | | | | {Time Delay for go51: o Sos! operating frequency ts one ~ bie dip, ¢ ‘hay of tha coplal ery J. One machine cycle laats fos 12 Oscihatos 5. (2 Machfne cycle Period * Cpt Banos ‘¢ Crysta Poqoncy "0892 MHZ om machine cycle pertoc) = Nos ! : =hOkS Le, Thatruction Machine ayele time to erecute MoV Ro. #0 i [1-085 MS -1.06o fag IDINZ Ri, Skip 2 Dl OR SHS = 2.16 MUL. A,B 4 HX} 08S HS = hu ug —— Calculate the time oleloy Produced by ta follousing Subroutine Delay: Mov RI, #30 HERE : Dayz. Ri, HERE Nop Nop RET | SoD: Lee us ardsume the coystat Proquency of Boot ts I)-05%2n 2 ie - = WoBqaxic® =|-085 MSec Tnatmiction Machine cycle Mov RI, #25 t ees DINZ RI,HERE 2 — exeate | 308 Nop ! Nop ! RET i Sec Time deloy = [y+ C2x 30) 4 HIF I DX POSS bt =69-HH MS » arming paraliel Ports :- - -@s) laid Do pi 1) gp hos 32 DIlo pins - con unceel as four eight -bie payatiel ports C Po. PI> P2 Pa). a AM ie ports ane bielisectional . # witiplexed except the pins of port |- All post - pins Ve ss je Foch post Consits ef a fatch ,an ojp and an ‘|p, port opin 32-39): oe 3 Post 0 pins can be ured oa To pina. wn ¥ ACCeAS external memory 2 yy Outputs tho Lev oxcler byte. ‘ exd/ data bur- # Usedl eA ao muttiplexed aeleryers date bus | | NK a | Fox] i i LPia | | Po-x | Laker ilo Pere wee ele a ie ee contxol logze Fig: port O bit =@)+ Port I pins can be used only ax To pins. Nee m I (oy t > I Pex pear eo a poate Fig: post U bye | “EK Used to access external memory. 36 Pore 2 outputs the high ovdest byte - # Addwess is Ib bits. pac be Vee: #* Porta i used as an T/o post. < antesnal oe | putl-up sate 8 Fig post 2 bit APoxt 3 C pins to -1): port 3 cote multifunctional ‘g Each pn te we Tlo or one of Re albernate function 4 They have teo0 external intevupls , tue counter */P> tvco dale ing and two Heating contssl Stwobes . Sa <3 d BYE ge” ee ge Pak ae cL parce e pw eer age™ Fig: post 3 bit 8) mets and Sevial Pork: - nme eb ss synopse> a Timers l) Structuye of ‘TMOD Regtstey . 2) Skeuctuve of TCON Regi ben x Trimet moclea, and Programming . as mens * : ag G05! has two timers + Lime O ancl Emex |- ye Both Hime Cand merit are Ib -Bik wegisters. ye Accessecl as toco’ byte ard hegh Byte negister. x Registers can be accessed [%ke other meguter> CA, B,Ro,Rrete). timer anegistey (alc Timen O negisten no = ewe) | [cos | Time Contwl Creow) veqi Sen Timmer meocte. CTMOD) register [ Figz Timon negister \ Steucture of -Tmob ister : TMopd ~- Timest/Counten Mode Contset Gate | fF | Mi Timers 1 Fig : yep Regidey 4 Select timer D ~» Operate counter ov timer. ee we Seleck Timer |—> ” ” ” “ te Mocle . *% MpMo t These bibs seleck We mor 0 ole 2 . SB NPos Birman rede O, Me : Yoh atipfe rent modes of tro model, melo 2. | Mi | Mo [ operating mocle ° ° @ IL C prescerlon ) o I Ik BIL Ccadcaced ;no prescalen) | ° gS bre Cre lod , overt flores) ’ laa Tima D> % bre I l ctimer_1~>_Steppedt C/F: BU ts cleaved ( C/Fz0)s Selecting Fimo See Cc/Fe)> Selecting countes- GATE: * Eating contro? urhen Seb. Wome en ” or ts Wahi. * "Xx" Ts enabled only chile "INTx "pin o& * "TRx ” contywl bit is Set. when “x” & encudlel whenover "TRx" Contwl bit is Set- Séeucture of Teow Reg ister : CMSB) (Lse> zt] reo| 170 | TF! | TRI| Tro | Tro| ze TFI : TON. > Timer | exerflovs fig: Set by hyo. thevtupt precersect TRI: ‘Toon. & > Timet 1 run bit. Sto. entervapl processed? * TCON- 5 —> Timex D overflow flag - Set by hiw. TRO > TCON- 4) > Biner O Run- S{w, oFe [TE] = TCON. 3 —> anterwtupl | Cedge flog). Set hi. cleawel Sp IFo PT oor) 1 TCON:2 “> Inbewupl) , lio and ex eD 60! »qTcoN-1 > Inkevurpt 0 . sek hlio and cleayed zp bin 2 TCON-0 > Intevtupt O, giro and external Anteviupe¢ery bos qimet Modes and Progamming : Tree we fous mocles of timex, mode 0, mode 1, mod 2 anol mode 3. poe * Mode O axe @-bit Counter . x Divide by 32 prescoden . #13-biE timex is MCS~4g Compatrble . Mode 0 operation, Count rolls over prom ails +o all Os. when TRi =! and etthet GATE = 0 Cox) INTL =| cf F=) Tl re re “De ae oo | FEW PIN beatae A Mode | = #¥ Ib bit Counter. # Count vila over Prorn at ts. to all Os, # Sets the Thmer interrupt flag TF. Es =1M * Topuk i enalled to the timo cohan TR= I Gtho: GATEHD os INTI=!- Timex Jcounten a1 Control togic. | contre, ERO rina coll Lage Time ce Fay. Hf EC) isa Me 2igi2 aay a mee | xTx]x [xP elo To (ele Mock 2°: * 8b £ counters with automatic veloacl. | x potds 7 Count - ip setting TRI =9- "primer O ih mode 3 > THO and np tod Separate counterrs Ibi: c/s = een ae TED » contvol bibs : ole GATE» TRO, INTO anc TED. 4 THO, controls the Time Uintervtrpe [pafeupt Mode 0 « 13 bit Hmen. 16 — bit FE Mode 1+ Mode 22 @~ bre counter, ; Mode 3.7L and TH has boo Seperate counters . Note: T have waitten owt mocks fost timer). Sindilosy, ‘You “have to r | © | i _* Sesial Port :- Synopsis : * Seviat post — Tronamission - Reception — BFE pattern of Scon Register.and PCON. * Operartin g Mrocles fox Sexiat port . * Grenerating Beaute Rates * Programming 8051 for Sevial Duta Transfer Programming go51 for Recetving Sata Sevially ¥* Rowrling the Baud Rate th tho gost ¥ Gos! Connection ty Rs 232¢. *® Serial communication prtogramnefng un C. Sexfat port: # The Sestal Port of gos) is fan duplex. * Ttean WanamPe anel seceive Simuttaneoumy. a USea *egistess SBUE to holel date. Register scon and Pon controls olata sales. * Pin RxD(P3.0) ancl TxDCp3.1) > data transfer. FOS. if yeqistert Ts hipe 4) ee Faenttf 7 ED % CP3-1) Bow a Bauel Yate cere clock | comer CRead only 9 Cant) ee S05) internal Bus ——_____£08) Intexnaf gus 4 SBUF ts an 8-bit eee : eae x Tks addvess bs 99H- i ae weiting to SBUF Ivack data to be tsansmitted and veadi; SBUF accesses wecetved cata. "4 % TWo Seperate Regirtent : » write ~ only Register. 2) Recetve neacl ~ only Reg ister. IPranamission : 3% Bata is to be tvansmittted vie the TxD pin- % SavF ts Loaded with this data byte. | Data byte is covitten into SBUF—> start and Stop bib - Reception + XK BOS! Heceives data Sexiatty via RxD Ben # Go5I defiames it - ‘ # Skoxt and Stop bis aw cepatolod | owk from a bye. # Byte b placed in spur xaegister. BiE a af Scon register + foe = & 4 2 l os | [ smo[ smi smz | REN Tae] Rae| TERE | | SMp = Scon 7 —> Conket bit O- SM: Scon 6 > contw bit I | &M2 = contyel bik 2. CScon-5) REN : scon- >> Receiver Enable . TRE: ScoN- 3 —> Tyarsmit Bik g. RBE = ScoN-2 —> Recetve Bre. TI + ScoN.) —> sramamit Intewmpt RD: Scon. 0 —> Receiw Tnterrupt Free). incede ae or Soarepe veqater 5 baucl 1 ° 1 Le bie DART, be - 1 e o a ? no, ba [iar ss oe stale x Bit pattern o. on vegtaster: 3 ee pes Clsay es oy cae eee be 6 [sve — [= | — Jar: [Gre | Po [=o] SMob : Pcon-7 —> D ak vesek - lat double baud Yate POON. 6-4 —> not clefined Ort PCON. 3 > Flag bit }- GiFo PCON-2 > Flag bre O- PD Pon.) 5. povver clown bre. IDL Pcon-.o —> Tale mode bre. : i it addrtessarle Note: Pcon not bik a Dperating Moctes fox Seviol port : = Scou lata enters and exit through RxD. ¥* TxD ocutpuls the Shift clock: #2 bi axe transmitted /Recatved’(1-S5) # Boud siate t fied ak Wiz the oscillator funu Mode 1: 3 (0 bik ane Leansmittted tRowugh Tx D. Received (Ry * A stot bit (0), 8 data bits CLSB) and stop bit) *¥ Baud vebe is Variable. Mode 2 : 4) bibs arte bransmitted . HA Stoxt bik (0), 8 data bils CLs@) and a « SteP 4 Tyanamit, tho th data bit CTBS in Seon) 4 SCON bik De © ignored. bit ¥ Baud vate is programmalle Ee ot ose. pews Mocle_3 = co 4 WbIES ate Leansmfttech. HA Stovtt bIE (0), 8 data bibs and 9 cata bit C1. x Baud wate th Mode 3 is varialle. Grenenating Baud Rotes : Jal Post tn Mode 0: x Mode 0 has a fixed baud wate - x VID of the oSeiiiater Ppequency TD stun the Serticl pert In this mede (get ap), ¢ SCON weqisters + Baud vate = Osillabos frequency - 1 ene Sexal post Tn Mode L: ve 4 Mode) har a variate baud Yate - 4 Bauol wate can be genvrcce ol by either Timer 1 ox Timet 2 C8052 only) lysing timex / counter ito Grenorate Baud Rate : Timest 1 is used tn mode 2 (Auto - Reload) Bausli tate = kK xX Osdtlates frequency ; Bo xl2 x [¢256-TH (PEt a 22 Smobd =o. then K=1. TE SmMoD =), thon K=2. tate THI : Ce k x Osctiiatow Frequency ~~ b— THIS 25 Ben X Bod wake FHICHEX) | Baudvale (Mop=0) | Baud vate (eMob FO qeoo 142000 | FA Heo Avoo i Fy 2HoO Hgvo | Fe 12.00 aloe! aa Note: XTHL = ))-O592 MERZ USing Timer/ counter 2 te Ce es) Clocked trough pin Ta. CPI-0). Times 2 overflow Hale fe ' Baul sate = ib Osciiiatos frequency : te = fi Bed al 32.xP 65536 ~ CRA PH. Reape Reload Value : Oscrilactov f,, RCAP2L =6563b6— Men RCAP2H , RCA 32> eeuaha | Serial Port tn mocle 2 + E 1 : SMob=1, Baudyate Say Oscitater Pequencyy Smop = 1 Stiettor > b= oscii | Bourcdscrte — th Srl) Preequercey The aclebwots of prow is SH. Seval_post th mode a. The baud Yate in mocle 2 2s Veotiable and Sets up Cxactfy the Same ay tn Mecle I. Programming 8051 fon Sevial Pata Teansfen : * Load the TMOD —> G-bit auto~'seloacl (26H) # boa TH) > Bowe yate for sorta? * Load SCON > BoH, mode | — > S bit * Sek TRI & 1 de stant Emons. # Clear TTD wth CLR TT ‘natruction # Wtite a chatacters SBUF vegister x Check the TI flag brL 5 JNB TL, xxxX _ | xe Goto Step 5 t transfer the next Choriacte | "ORL pcon, $f SoH). P pogo See! FOX necewng Bata Seatly : = Joacl He “TMoD Registers 20H (e@-EL « i Aa oad THL —S Set the desvie baud vote eae? p load SON —> Value DM, Sexfal mode I> @—bYE ye Sek TRI to 4 to Start timer) - x cleo RE with CLR RI Instwiction y check the RT flag > NB Ri, XXxx x oP RE B Seb, SBUF has the lbyte- Save this byte 4 Got step 5 to Mecive te Next character. pousting the Bowd vote & the Zoot? Two LOL» Le » By doubling the cxyptal Frequency making SMop bie in the pcon register frora Otol. 2) BY Rost comection to RS 232C 2 Fg. Connection bleo RS > Rg 232 Volt -. ) re ¥ i OGL FBV tw IBV PIGEO nares S -15V (foils eeealsicloal ¥ c Pra av aA logic | — “lr Rd 2320 e ¥ Connectfon blo and SoBt- Le Max 232 chip & ured ada dive? and Cine yecciver. ino qwwo PI Rep mt TxD - 2 he (p30 PCB) Serie! Comnunticotien progumding , fn c. * ROBT ane accessztble Hinectly in Some coneprilers by inclusion of the negsi-h file ioe ave fe icine, Wie edencesas pre Te and Ee [using bit data type. ee — Haterrupe Handling :- 8051 Thkevupt skvuctue= 8051 has 5 intervmpls.” ® Extertnat ‘interurpls 0 INTD db External intevupt 1 Int) & Timet 0 intepuypst (TED) "D Timex | intestupk CTF!) Serial communtcation ‘inkeruupt CRI /72) Intesviupt contyo) Reg ister (LE) CSFR) When S05) ty Set, au nterviupls cow olisa le. * They ase enabled b ELoouLe « " * a of these es can be. indeviclually enciloled 29h by getting ox cleaying - # A Bie iD cpectal function neyister TE. . TE contains global disable bit EA, which disables also lu, at ence. FA| -| #2 [es| ea Ext | &b | Exo. EA + TE.7 —y Enables ant contsn? Lik. Cleasted by Software to disable all tnkenup bs — :TE.6 > Resexnved . FIR + TE-5 + rReswaved ES 7 TE. h —> Enables serial post contro? bie. a? Set | cleaned) by Software tp enable | table ‘inlerviupry from TI / RT fogs. FEM —5TE.3 —s Enable timext conte bit. Set | Cleoxed bY Softicare. to enable [disable ‘inkevurpts from Timon] counter 1. MS@_ 4 & ex VP AE Te mene SAU Tee ULDE 4 Conte 37 Fe Set [cleared by Softuasr is enalsle | discble in Lertupts fro m INT). pore! —> Enable timex © control Wik Set/cleaxed by Softiocwe tv enalsle / disatola ‘Inkeroupt frorn Hmert [counter 0. Exo —2IF.0 Enable exteinal inteoupt o Contr bre Sek clecvwd boy Softuae te encrtse of [disable | ‘nteviupts fiom xT. Sn Hn 2 bneertupt priority and Tnkeviupt olertinertion + gach intevit Source can be Pregrarnmed by Species unction register by “Tp” ! oO =lLes | pray pxa |_pto | Px | Simultaneous Py - PTI. DP > timen prion’ - Set /cleasuel oy Slo te cpectty high |Iove provly ntevurple fon met 1 counters, tp.1 to IP.S > Reserve ol rp. 4: PS—> Sertal port PYoviby contre? br . Set | Cleared by Soft voce bo Spec by high / tov PMevly ‘nkerupls for Seal port. Contest bie- PasTpP2 —S External intevapt 1 previty Control bPt. (set by Slo for TNT) PTO.TP.1—> Timer 0 phorviky conto? Cset by slo for Hime PO TP oy external “Mlovmpls D protky Cset fox Tyo). TP too mequess of different py bre Jeounter ©) Conbes? bie- fly Jevels axe recezvel | i) The srequest of highest povity devel eae ee a ved Si erp sequests af Same priovity fev ase Neco SMa 7 fived . Hotenrinos woRich request to be SOM : — Thhewrupt Neck / location pow by Ext, Who tneoupl DT | 0003H hi t Timest O inkewtupt TFo] cooBy Ext - hardware “nbersupt inri 0088 4 Timer 1 inteoiupt TE) | do1B 5 Sexia} communication 0023 4 Lowest (RE and TI) Table + Intevupt Vectos alle. dayv7)

You might also like