Power point about Controller

Embed Size (px)

Citation preview

  • 7/24/2019 Power point about Controller

    1/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-11

  • 7/24/2019 Power point about Controller

    2/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-22

    The Silicon Micro System is a pioneer company in manufacturing and

    distribution of electronics equipment's in the field of VLSI,

    EMBEE, !L" #$T%M#TI%& "%MM$&I"#TI%& S(STEMS

    since )**+

    The company has - di.isions

    Mar/eting

    "ustomer support

    e.elopment

    Training

    The company pro.ides technical solutions for .arious fields li/e

    Engineering, !olytechnic, Science and $ni.ersity "olleges and total

    lab setup

  • 7/24/2019 Power point about Controller

    3/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-33

    The 012) Microcontroller

  • 7/24/2019 Power point about Controller

    4/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-44

  • 7/24/2019 Power point about Controller

    5/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-55

    3eatures of 012) Microcontroller

    -1*4 bytes on5chip program memory)60 bytes on5chip data memory0 bit Microcontroller

    3our register ban/s%ne microsecond instruction cycle 7ith )6 M89 crystal:6 bidirectional I;% lines organi9ed as four 0 bit portsMultiple mode, high speed programmable serial port

    )45bit timers;countersT7o le.el prioriti9ed interrupt structure

  • 7/24/2019 Power point about Controller

    6/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-66

    8051 Basic Component

    4K bytes internal ROM 128 bytes internal RAM

    Four 8-bit I/Oports(P0 - P3!

    "#o 1$-bit ti%ers/&ounters

    One serialinter'a&e

    RAM

    I/O

    PortTimer

    SerialCOMPort

    Microcontroller

    CPUA single chip

    ROM

  • 7/24/2019 Power point about Controller

    7/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-77

    Block Diagram

    "!$

    Interrupt

    "ontrol

    %S" Bus"ontrol

    -/

  • 7/24/2019 Power point about Controller

    8/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-88

    Other 8051 featurs

    only 1On &ip os&illator(e)ternal &rystal

    $ interrupt sour&es (2 e)ternal * 3 internal* Reset

    $4K e)ternal &o+e(pro,ra% %e%ory(only

    rea+P.

    $4K e)ternal +ata%e%ory(&an be rea+ an+ #rite

    by R*R

    o+e %e%ory is sele&table by .A(internal or

    e)ternal

    e %ay ae .)ternal %e%oryas +ataan+ &o+e

  • 7/24/2019 Power point about Controller

    9/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-

    Embedded System(8051 Application

    =hat is Embedded System> An e%be++e+ syste% is &losely

    inte,rate+ #it te %ain syste% It %ay not intera&t +ire&tly #it te

    eniron%ent For e)a%ple A %i&ro&o%puter in a

    &ar i,nition &ontrol

    #n embedded product uses a microprocessor or microcontroller to do one

    tas/only

    There is only one application soft7are that is typicallyburned into

  • 7/24/2019 Power point about Controller

    10/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-1!1!

    !hree criteria in Choosin" aMicrocontroller

    Meetin, te &o%putin, nee+s o' te tas5e6&iently an+ &ost e7e&tiely

    spee+* te a%ount o' ROM an+ RAM* te nu%ber o'I/O ports an+ ti%ers* sie* pa&5a,in,* po#er

    &onsu%ption easy to up,ra+e &ost per unit

    Aailability o' so't#are +eelop%ent tools

    asse%blers* +ebu,,ers* &o%pilers* si%ulator*te&ni&al support

    i+e aailability an+ reliable sour&es o' te%i&ro&ontrollers

  • 7/24/2019 Power point about Controller

    11/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-1111

    8051 Internal Block Diagram8051 Internal Block Diagram

  • 7/24/2019 Power point about Controller

    12/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-1212

    8051

    SchematicPin out

  • 7/24/2019 Power point about Controller

    13/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-1313

    8051

    Foot Print

    1

    2

    3

    5

    !

    "

    8

    #

    10

    11

    12

    13

    1

    15

    1!

    1"

    18

    1#

    20

    0

    3#

    38

    3"

    3!

    35

    3

    33

    32

    31

    30

    2#

    28

    2"

    2!

    25

    2

    23

    22

    21

    P1$0

    P1$1

    P1$2

    P1$3

    P1$

    P1$5

    P1$!

    P1$"

    %&'

    (%)D*P3$0

    (')D*P3$1

    ('0*P3$

    ('1*P3$5

    )'A+2

    )'A+1

    ,-D

    (I-'0*P3$2

    (I-'1*P3$3

    (%D*P3$"

    (.%*P3$!

    cc

    P0$0(AD0

    *P0$1(AD1*

    P0$2(AD2

    *P0$3(AD3*

    P0$(AD*

    P0$5(AD5*

    P0$!(AD!*

    P0$"(AD"*

    EA/PP

    A+E/P%,

    P&E-

    P2$"(A15*

    P2$!(A1

    *P2$5(A13

    *P2$(A12

    *P2$3(A11*

    P2$2(A10*

    P2$1(A#*

    P2$0(A8*

    8051(8031*

    (8"51*

    (8#51*

  • 7/24/2019 Power point about Controller

    14/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-1414

    IMPORTANT PINS IO Port!"IMPORTANT PINS IO Port!"

    ne o te most useul eatures o te 8051 is tat it containsour I/ ports (P0 P3*

    Port 0Port 0 pins 32-39pins 32-39 P0P0 P0!0P0!0 P0!:P0!: 8-bit R/ - ;eneral Purpose I/O8-bit R/ - ;eneral Purpose I/O OrOra&ts as a %ultiple)e+ lo# bytea&ts as a %ultiple)e+ lo# byte a++ressa++ressan+an+ +ata+atabus 'orbus 'or e)ternale)ternal

    %e%ory +esi,n%e%ory +esi,n

    Port 1Port 1 pins 1-8pins 1-8 P1P1 P1!0P1!0 P1!:P1!: OnlyOnly8-bit R/ - ;eneral Purpose I/O8-bit R/ - ;eneral Purpose I/O

    Port 2Port 2 pins 21-28pins 21-28 P2P2 P2!0P2!0 P2!:P2!: 8-bit R/ - ;eneral Purpose I/O8-bit R/ - ;eneral Purpose I/O OrOri,i,byte o' tebyte o' te a++ressa++ressbus 'or e)ternal %e%ory +esi,nbus 'or e)ternal %e%ory +esi,n

    Port 3Port 3 pins 10-1:pins 10-1: P3P3 P3!0P3!0 P3!:P3!: ;eneral Purpose I/O;eneral Purpose I/O i' not usin, any o' te internal periperals (ti%ers or e)ternali' not usin, any o' te internal periperals (ti%ers or e)ternal

    interrupts!interrupts!

    Eac port can 4e used as input or output (4idirection*

  • 7/24/2019 Power point about Controller

    15/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-1515

    Port # Alternate Function!

  • 7/24/2019 Power point about Controller

    16/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-1616

    IMPORTANT PINSIMPORTANT PINS

    PSENPSEN(out

  • 7/24/2019 Power point about Controller

    17/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-1717

    Pin! o$ 8051

    @&& pin 40@&& proi+es supply olta,e to te &ip!"e olta,e sour&e is B@!

    ; pin 20 ,roun+

    C"A=1 an+ C"A=2 pins 19*18"ese 2 pins proi+e e)ternal &lo&5!

    ay 1 usin, a Duart &rystal os&illatoray 2 usin, a ""= os&illator.)a%ple 4-1 so#s te relationsipbet#een C"A= an+ te %a&ine &y&le!

  • 7/24/2019 Power point about Controller

    18/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-1818

    Ma&ine &y&le

    Fin+ te %a&ine &y&le 'or

    (a C"A= E 11!0B92 M

    (b C"A= E 1$ M!

    Solution:

    (a 11!0B92 M / 12 E 921!$ 5G

    %a&ine &y&le E 1 / 921!$ 5 E 1!08B s

    (b 1$ M / 12 E 1!333 MG

    %a&ine &y&le E 1 / 1!333 M E 0!:B s

  • 7/24/2019 Power point about Controller

    19/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-11

    Pin! o$ 8051

    R" pin 9 reset input pin an+ a&tie i, nor%ally lo# !

    "e i, pulse %ust be i, at least 2

    %a&ine &y&les! po#er-on reset! >pon applyin, a i, pulse to R"* te%i&ro&ontroller #ill reset an+ all aluesin re,isters #ill be lost!

  • 7/24/2019 Power point about Controller

    20/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-2!2!

    Pin! o$ 8051

    ;E#pin :) e?ternal access There is no on5chip

  • 7/24/2019 Power point about Controller

    21/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-2121

    Pin! o$ 8051

    #LEpin :1 address latch enable It is an output pin and is acti.e high

    012) port 1 pro.ides both address and data

    The #LE pin is used for de5multiple?ing theaddress and data by connecting to the @ pin of the+-LS:+: latch

  • 7/24/2019 Power point about Controller

    22/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-2222

    Address Multiple#in"for E#ternal Memory

    Figure 2-7

    Multiple)in, te

    a++ress

    (lo#-bytean+ +ata

    bus

  • 7/24/2019 Power point about Controller

    23/58hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-2323

    Address Multiple#in"for E#ternal Memory

    Figure 2-8

    A&&essin,e)ternal

    &o+e%e%ory

  • 7/24/2019 Power point about Controller

    24/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-2424

    Accessin" E#ternal$ata Memory

    Figure2-11

    Inter'a&e to 1K

    RAM

  • 7/24/2019 Power point about Controller

    25/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-2525

    E#ternal code memory

  • 7/24/2019 Power point about Controller

    26/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-2626

    E#ternal data memory

    012)

  • 7/24/2019 Power point about Controller

    27/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-2727

    O%erlappin" E#ternal Codeand $ata Spaces

  • 7/24/2019 Power point about Controller

    28/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-2828

    O%erlappin" E#ternal Codeand $ata Spaces

    Allo&s the 'AM to be

    &ritten as data memory and

    read as data memory as &ell as co%e memor&)

    !his allo&s a pro"ram to be

    do&nloaded from outside into the 'AM as data and

    e#ecutedfrom 'AM as code)

  • 7/24/2019 Power point about Controller

    29/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-22

    On*Chip Memory+nternal 'AM

  • 7/24/2019 Power point about Controller

    30/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-3!3!

    'e"isters

    1+14121-1:161)11

  • 7/24/2019 Power point about Controller

    31/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-3131

    Special ,unction 'e"isters

    $A!A re"isters

    CO!'O2 re"isters

    !imersSerial ports+nterrupt systemAnalo" to $i"ital con%erter

    $i"ital to Analo" con%erterEtc)

    Addresses 80h 3 ,,h

    $irect Addressin" usedto access S4's

  • 7/24/2019 Power point about Controller

    32/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-3232

    Acti%e ban- selected by 4S 6RS1'RS07 bit

    4ermits fast conte#t s&itchin"9 in interrupt

    ser%ice routines (+S')

    'e"ister Ban-s

  • 7/24/2019 Power point about Controller

    33/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-3333

  • 7/24/2019 Power point about Controller

    34/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-3434

    8051 C4: 'e"isters

    A (AccumulatorB4S (4ro"ram Status ordS4 (Stac- 4ointer4C (4ro"ram Counter$4!'($ata 4ointer

    :sed in assemblerinstructions

  • 7/24/2019 Power point about Controller

    35/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-3535

    Regi!ter!

    A

    (

    R!

    R1

    R3

    R4

    R2

    R5

    R7

    R6

    DP) DP"

    PC

    DPTR

    PC

    Some 8!51 16-*it Re+i,ter

    Some 8-*it Re+i,ter,

    o t.e 8!51

  • 7/24/2019 Power point about Controller

    36/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-3636

    !he 8051

    Assembly 2an"ua"e

  • 7/24/2019 Power point about Controller

    37/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-3737

    O%er%ie&

    ata trans'er instru&tions

    A++ressin, %o+es

    ata pro&essin, (arit%eti& an+ lo,i&

    Pro,ra% Ho# instru&tions

  • 7/24/2019 Power point about Controller

    38/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-3838

    $ata !ransfer +nstructions

    MO@ +est* sour&e +est sour&e ta&5 instru&tions

    PUSH byte ;increment stack pointer,;move byte on stack

    POP byte ;move from stack to byte,

    ;decrement stack pointer .)&an,e instru&tions

    XCH a, byte;exchange accumulator and byte

    XCHD a, byte ;exchange low nibbles of;accumulator and byte

  • 7/24/2019 Power point about Controller

    39/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-33

    Addressin" Modes

    I%%e+iate Mo+e spe&i'y +ata by its alue

    mov A, #0 ;put 0 in the accumulator

    ;A = 00000000

    mov R4, #11h ;put 11hex in the R register ;R = 00010001

    mov B, #11 ;put 11 decimal in b register

    ;! = 00001011

    mov DPTR,#7521h ;put "#$1 hex in %&'R ;%&'R = 0111010100100001

  • 7/24/2019 Power point about Controller

    40/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-4!4!

    Addressin" Modes

    I%%e+iate Mo+e &ontinue

    MO DPTR,#7521h()* %&+,$1-

    ()* %&-, "#

  • 7/24/2019 Power point about Controller

    41/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-4141

    Addressin" Modes

    Re,ister A++ressin, eiter sour&e or +estination is one o'P> re,ister

    MO R0,AMO A,R7

    ADD A,R4

    ADD A,R7

    MO DPTR,#25!5H

    MO R5,DP"

    MO R,DPH

    otethatMO R4,R7$% $&'o((e't

  • 7/24/2019 Power point about Controller

    42/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-4242

    Addressin" Modes

    ire&t Mo+e spe&i'y +ata by its 8-bit a++ress

    >sually 'or 30-:F o' RAMMov a, 70h ) 'o*y 'o&te&t% o+ RAM at 70h to a

    Mov R0,40h ) 'o*y 'o&te&t% o+ RAM at 70h to a

    Mov 5h,a ) *-t 'o&te&t% o+ a at 5h to a

    Mov 0D0h,a ) *-t 'o&te&t% o+ a $&to PS.

  • 7/24/2019 Power point about Controller

    43/58

  • 7/24/2019 Power point about Controller

    44/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-4444

    Addressin" Modes

    Re,ister In+e)e+ Mo+e sour&e or +estination a++ress iste su% o' te base a++ress an+ tea&&u%ulator(In+e)

    Jase a++ress &an be P"R or Pmov *t(, #4000h

    mov a, #5

    mov' a, a 9 *t( ;a (.00#/

  • 7/24/2019 Power point about Controller

    45/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-4545

    Acc 'e"ister

    Are,ister &an be a&&esse+ by +ire&tan+ re,ister%o+e

    "is 3 instru&tion as sa%e'un&tion #it +i7erent&o+e

    0703 :500 mov a,00h

    0705 ;500:0 mov a'',00h

    070; ;500:0 mov 0e0h,00h

    Also tis 3 instru&tion070B :8 mov a,(1070C ;8:0 mov a'',(1

    070: ;8:0 mov 0e0h,(1

  • 7/24/2019 Power point about Controller

    46/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-4646

    E#chan"e +nstructions

    t#o #ay +ata trans'erXCH a, 30h ) a M306

    XCH a, R0 ) a R0

    XCH a, R0 ) a MR06

    XCHD a, R0 ) e'ha&e $$t

    R0."/ R0.0/a."/ a.0/

    %nly - bits e?changed

  • 7/24/2019 Power point about Controller

    47/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-4747

    ata Pro&essin,

    Instru&tionsArit%eti& Instru&tions

    =o,i& Instru&tions

  • 7/24/2019 Power point about Controller

    48/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-4848

    Arit%eti& Instru&tions

    A++

    ubtra&t

    In&re%ent

    e&re%ent Multiply

    ii+e

    e&i%al a+ust

  • 7/24/2019 Power point about Controller

    49/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-44

    Arit%eti& Instru&tions

    Mnemonic De!cri(tion

    A%% A, byte add A to byte put result in A

    A%%2 A, byte add &ith carry

    34!! A, byte subtract &ith borro&

    562 A increment A

    562 byte increment byte in memory

    562 %&'R increment data pointer

    %72 A decrement accumulator

    %72 byte decrement byte(4+ A! multiply accumulator by b re"ister

    %5* A! di%ide accumulator by b re"ister

    %A A decimal ad;ust the accumulator

  • 7/24/2019 Power point about Controller

    50/58

    hsabaghianb @ kashanu.ac.irhsabaghianb @ kashanu.ac.ir MicroprocessorsMicroprocessors1-1-5!5!

    A Instru&tions

    add a, byte ; a a 8 byteaddc a, byte ; a a 8 byte 8 2

    "ese instru&tions a7e&t 3 bits in P