unit viii microcontroller

Upload: adithya123456

Post on 30-May-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 UNIT VIII Microcontroller

    1/19

    UNIT-VIIIMicrocontroller

    Microcontroller contains a microprocessor with I/O

    Ports, minimum memory and programmable timer. Advantages of microcontroller

    As the peripherals are integrated into a single chip, theoverall system cost is very low and system is morereliable.

    The size of the product is small as compared to themicroprocessor based systems thus very hands. The system design requires very little efforts and is easy

    to troubleshoot and maintain. Though a microcontroller may have on-chip RAM, ROM

    and I/O Ports, additional RAM,ROM and I/O Ports may be

    interfaced externally, if required. The microcontroller with on-chip ROM provide a software

    security feature which is not available withmicroprocessor based systems using ROM/EPROM.

    All these features are available in a 40 pin package as inan 8-bit processor.

  • 8/14/2019 UNIT VIII Microcontroller

    2/19

    Microcontroller internal block diagram

    o As a microcontroller contains most of the

    components required to form a microprocessorsystem, it is sometimes called a single chipmicrocomputer.

    o

    The earlier versions of Intels microcontroller donot have on-chip EPROM.

    o 8051 also do not have on-chip EPROM.

    o 8751 is 1st

    version with on-chip EPROM.

    o 8051 has 128 RAM, four 8-bit I/O ports, twoTimers (16 bit).

  • 8/14/2019 UNIT VIII Microcontroller

    3/19

  • 8/14/2019 UNIT VIII Microcontroller

    4/19

    Architecture of 8051

    1. Accumulator (ACC or A)

    ACC act as an operand register, in case of some instructions. The

    ACC register, has been allotted an address in the on-chip specialfunction register bank.

    2. B-Register

    This register is used to store one of the operands for multiply anddivide instructions. (In other instruction it is used as a scratch

    pad.) This register is considered as a special function register.

    3. PSW-Program Status Word

    This set of flags contains the status information and is consideredas one of the special function register.

    4. SP-Stack Pointer

    This 8-bit wide register is incremented before the data is storedonto the stack using push or call instructions. This registercontains 8-bit stack top address.

  • 8/14/2019 UNIT VIII Microcontroller

    5/19

  • 8/14/2019 UNIT VIII Microcontroller

    6/19

    8. Timer RegistersThese two 16-bit registers can be accessed as their lower &upper bytes i.e

    register 0 TL0, TH0Register 1 TL1, TH1All these register can be accessed using the 4 address allotted to them

    which lie in the SFR address range i.e 80h to FFh.

    9. Control RegistersThe special function registers IP, IE, TMOD, TCON, SCON & PCON

    contain control and status information for interrupts, timers,counters and serial port.

    10. Timing & Control unitThis unit derives all the necessary timing and control signalsrequired for the internal operation of the circuit. It also derivescontrol signals required for controlling the external system bus.

    11. Instruction RegisterThis register decodes the opcode of an instruction to be executedand gives information to the timing and control unit to generatenecessary signals for the execution of the instruction.

  • 8/14/2019 UNIT VIII Microcontroller

    7/19

    12. EPROM and Program Address Register (PAR)These blocks provide an on-chip EPROM & amechanism to internally address it (it is not in 8051).

    13. RAM & RAM Address RegistersThese blocks provide internal 128 bytes of RAM and amechanism to internally address it.

    14. ALUTMP1 & TMP2 holds the operands, users cannot access.

    15. SFR Register BankThis is a set of SFRs(special function registers), whichcan be addressed using their respective address whichlie in the range 80h to FFh.

  • 8/14/2019 UNIT VIII Microcontroller

    8/19

    Sunday, November 22, 2009 GRIET 8

    Pin Description of the 8051

    PDIP/Cerdip

    1234567

    891011121314151617181920

    4039383736353

    433323130292827262524232221

    P1.0P1.1P1.2P1.3P1.4P1.5P1.6

    P1.7RST(RXD)P3.0(TXD)P3.1

    (T0)P3.4(T1)P3.5

    XTAL2XTAL1

    GND

    (INT0)P3.2(INT1)P3.3

    (RD)P3.7(WR)P3.6

    VccP0.0(AD0)P0.1(AD1)P0.2(AD2)P0.3(AD3)P0.4(AD4)P0.5(AD5)

    P0.6(AD6)P0.7(AD7)EA/VPPALE/PROG

    PSENP2.7(A15)P2.6(A14)P2.5(A13)P2.4(A12)P2.3(A11)P2.2(A10)P2.1(A9)P2.0(A8)

    8051

  • 8/14/2019 UNIT VIII Microcontroller

    9/19

    Signals description of 8051

    Vcc -- +5v power supply

    Vss -- ground

    Reset It resets the 8051. It is an input pin and is active high The high pulse must be high at least 2 machine cycles.

    Upon applying a higwill h pulse to RST, the microcontroller will reset and all values in

    registers be lost.

    ALE/PROG ALE is valid only for external memory accesses. This pin

    acts as program pulse input during on-chip EPROM programming. ALEmay be used for external timing and clocking purpose. One ALE pulse isskipped during each access to external data memory. The ALE pin is usedfor de-multiplexing the address and data by connecting to the G pin of the 74LS373 latch.

    EA External Access Enable pin

    If it is low indicates that the 8051 can address external program

    memory. If it is high indicates execution of programs in internal memory.

  • 8/14/2019 UNIT VIII Microcontroller

    10/19

    This pin also receives 21 volts for programming of the on-chipEPROM.

    PSEN (Program Store Enable) it is an active low output signal that acts as a strobe to read theexternal program memory. This goes low during external programmemory accesses.

    Port 0 (P0.0 P0.7)

    Port0 is an 8-bit bidirectional bit addressable I/O port. This hasbeen allotted on address in the SFR address range. Port0 acts asmultiplexed address/data lines during external memory access, i.e.when EA is and ALE emits a valid signal. In case of controllers withon-chip EPROM Port0 receives code bytes during programming of the

    internal EPROM.

    Port 1 (P1.0 P1.7)

    Port1 acts as an 8-bit bidirectional bit addressable. This has beenallotted an address in the SFR address range.

  • 8/14/2019 UNIT VIII Microcontroller

    11/19

    Port 2 (P2.0 P2.7)

    Port2 acts as an 8-bit bidirectional bit addressable. This hasbeen allotted an address in the SFR address range. During

    external memory access, ports emits higher eight bits ofaddress(A8-A15) which are valid, if ALE goes high and EA is low.P2 also receives higher order address bits during programming ofthe on-chip EPROM.

    Port 3 (P3.0 P3.7) Port3 acts as an 8-bit bidirectional bit addressable. This hasbeen allotted an address in the SFR address range. The port3 pinsalso serve the alternative functions.

    XTAL1 & XTAL2

    -- There is an inbuilt oscillator which derives the necessary clockfrequency for the operation of the controller.

    XTAL1 is the input of the amplifier

    XTAL2 is the output of the amplifier

  • 8/14/2019 UNIT VIII Microcontroller

    12/19

    Alternate Functions of Pins of Port3

    Port 3 pins Alternative FunctionP3.0 Acts as serial input data pin (RXD)

    P3.1 Acts as serial output data pin (TXD)

    P3.2 Acts as external interrupt pin 0(INT0)

    P3.3 Acts as external interrupt pin 1(INT1)

    P3.4 Acts as external input to timer 0 (T0)

    P3.5 Acts as external input to timer 1 (T1)

    P3.6 Acts as write control signal forexternal data memory writeoperation (WR)

    P3.7 Acts as read control signal forexternal data memory read

  • 8/14/2019 UNIT VIII Microcontroller

    13/19

  • 8/14/2019 UNIT VIII Microcontroller

    14/19

    8051 generates RD, WR during external datamemory access.

    Internal data memory (256 bytes) 128 bytes RAM

    Set of addresses from 80h to FFh (SFR)

    RAM can be addressed by using Direct or Indirect

    mode of addressing. SFR address map by Direct AM only.

    EXTERNAL I/O INTERFACING:--

    Some complex applications may require additionalI/O devices to be interfaced with 8051. Suchexternal I/O devices are interfaced with 8051 asexternal memory-mapped devices.

  • 8/14/2019 UNIT VIII Microcontroller

    15/19

    Interrupts of 80518051 provides 5 sources of interrupts

    INT0, INT1 :-These are external interrupt inputs.

    These can be either edge-sensitive or level-sensitive , asprogrammed with bit IT0, IT1 in register TCON.

    These are processed internally by the flags IE0, IE1.

    1. If the interrupts are programmed as edge-sensitive these flags (IE0, IE1) are automatically cleared after thecontrol is transferred to the respective vector.

    2. If the interrupts are programmed as level-sensitive

    these flags are controlled by the external interruptssources themselves.

  • 8/14/2019 UNIT VIII Microcontroller

    16/19

    Both timers can be used in timer or counter mode.

    In Counter Mode, it counts the pulses at T0 or T1 pin.

    In Timer Mode, oscillator clock is divided by a

    prescaler (1/32) and then given to the timer. So clockfrequency for timer is 1/32th of the controller operatingfrequency.

    The timer is an up-counter and generates an interruptwhen the count has reached FFFFh.

    It can be operated in 4 difference modes (0-3) that canbe set by TMOD register.

    The Timer0 and Timer1 interrupt sources aregenerated by TF0, TF1 bits of the register TCON.

    When these interrupts are generated, the respectiveflags are automatically cleared after the control istransferred to the respective interrupts service routines.

  • 8/14/2019 UNIT VIII Microcontroller

    17/19

    The serial port interrupt is generated, if at least one oftwo bits RI & TI is set.

    Neither of the flags is cleared after the control is

    transferred to the interrupt service routine. Priorities of interrupts

    All these interrupts are enabled using a special functionregister called Interrupt Enable Register (IE) & theirpriorities are programmed using another special functionregister Interrupt Priority register (IP).

    S.NO Interrupt source Priority withinlevel

    1 IE0 (External INT0) Highest2 TF0 (Timer 0) :

    3 IE1 (External INT1) :

    4 TF1 (Timer 1) :

    5 RI=TI (serial port) Lowest

  • 8/14/2019 UNIT VIII Microcontroller

    18/19

  • 8/14/2019 UNIT VIII Microcontroller

    19/19

    The 8051 UART( serial port) can beconfigured to use a 9th data bit thatcan provide addressable

    communications in an RS-485 multi-point communications environment.

    http://en.wikipedia.org/wiki/UARThttp://en.wikipedia.org/wiki/EIA-485http://en.wikipedia.org/wiki/EIA-485http://en.wikipedia.org/wiki/UART