overview of 8051

Embed Size (px)

Citation preview

  • 7/28/2019 overview of 8051

    1/7

    6/24/2013

    1

    PART II:PART II:

    Architecture of the 8051Architecture of the 8051

    Just as we have studied earlier in one of the previous classes, thatmicrocontrollers can be classified in various ways. The Family(manufacturer) being one of it, in this Part of the course we shall be

    putting into consideration one of the families of the microcontroller namely the INTE L family.

    In the INTEL group of family there are various types of microcontroller grouped into family of 8bits group (8XC42,MCS51,MCS48) , the 16bits group (MCS96, MXS296) and so on.

    Each of these groups has its distinct features that differentiates themfrom others and also within each group every member also has distinctfeatures that differentiates them from all other members in the group.

    However in this part of the course our concentration shall be on theMCS 51 family and in the family our attention shall be on the 8051microcontroller.

    Architecture of 8051

    The INTEL MCS 51 family is also known as the 8051 family, this is asa result of the popularity and the wide use of the family member 8051.This is owing to the fact of the large market share the member 8051enjoys almost all other microcontrollers since its introduction into themarket in the late 70s.

    The INTEL MCS 51 family consists of microcontrollers within the

    range of 8031 to 8751. That is to say all Intel microcontrollers that fallswithin the number range of 8031 to 8751 belongs to the family of MCS-51, otherwise known as the 8051 family.

    The MCS-51 are manufactured based on the CMOS and NMOSconstruction in variety of packages such as the DIP, PLCC etc.

    #what is C MOS,NMOS,DIP, PLCC?#CMOS(Complementary metal oxide silicon), NMOS(N- channel metaloxide silicon) , DIP (Dual-inline package), PLCC (Plastic lead chipcarrier).

    Architecture of 8051 Members of the MCS-51 and their features

    Presented below is a sample of a datasheet of the MCS51 familymembers. Basically the datasheet shows the basic features on eachmember in the family.

  • 7/28/2019 overview of 8051

    2/7

    6/24/2013

    2

    Members of the MCS-51 and their features (Contd) Basic Features of the 8051In the MCS 51 family our attention shall be on the 8051microcontroller. Some of the basic features of the 8051 includes thefollowing

    It is an 8 bit microcontroller, meaning the size of the data bus is 8 bit wide and also the CPU has the cap ability of processing 8bit of data once.It has a 16 bit Address bus4KB of on-chip ROM- for program storageA 256 byte of RAM for special functions and data,(128 byte for

    special function register(SFR) and 128byte for internal RAM)Has 4 ports 8-bits ports (I/O ports)5 interrupt (2-external and 3 internal sources)1 serial port.

    Can access up to 64KB of external ROMCan access up to 64KB of external ROM2 timer And lots more.

    Basic Features of the 8051The figure below illustrates and shows the features of the 8051 .

    Basic Features of the 8051ROM

    The 8051 is designed such that the memories for the program code anddata are divided into 2 separate physical entity (Harvard memoryArchitecture).

    The 8051 is equipped with an on-chip ROM of 4KB . This Internal4KB ROM is used to store program code. The program code can only

    occupy an address range of 0000h to 0FFFh , which corresponds tothe size of the ROM. The address range can be calculated as below:

    Capacity = End Address Start Address +1

    In this case we know the capacity to be 4KB and the start Address is0000h . Hence we can determine the End address by simple arithmeticoperationin hexadecimal to have 0FFF .

    The implication of the 0000h to 0FFFh is that the address range of thePC (Program counter ) is between 0000h-0FFFh representing a totalof 4KB locations that can be used to save program code.

  • 7/28/2019 overview of 8051

    3/7

    6/24/2013

    3

    Basic Features of the 8051ROM

    The 8051 microcontroller also has the capability to access up to 64KBof external ROM . Thus the 64KB address region will range from0000h-0FFFh for the external ROM . If this is used the microcontroller will have the capability of being able to store more program code.

    The use of the External ROM will increase the storage capacity of the8051. However some configurations needs to be done by the designer

    before the external ROM can be activat ed and also the designer willneed to specify the location of the program code, whether on theInternal ROM or external ROM or partially on both of them.

    RAMThe RAM are basically used for the storage of data in the

    microcontroller. The 8051 is endowed with a 256 byte Internalmemory which is divided into two, namely the SFR (special FunctionRegister) and the internal RAM which each have a 128byte capacity.

    Basic Features of the 8051The figure below illustrates the division of the RAM of the 8051 .

    Source:8051 tutorial by Donal Heffernan

    Basic Features of the 8051The first 128bytes of the internal Memory is designated as the internalRAM of the microcontroller otherwise called the IRAM . The IRAMis further divided into Register banks, Bit addressable RAM, GeneralPurpose RAM . The organization of the IRAM according to theaddressrange is as follows;

    Register Banks 00h to 1Fh (80 byte)Bit Addressable RAM 20h to 2Fh (16byte)

    General Purpose RAM 30h to 7F h(32 byte )

    The figure below shows the organization of the IRAM of the 8051.(next slide)

    The second 128byte of the 256byte Internal memory are for the SFR with address range of 80h to FFh . The SFRs are 21 in numbers andare used for specific functions only with each have address rangewithin 80h to FF h . Note : not all the 21 SFR are bit addressable .

    MEMORY

    B a s

    i c F e a

    t u r e s o

    f t h e

    8 0 5 1

  • 7/28/2019 overview of 8051

    4/7

    6/24/2013

    4

    B a s

    i c F e a

    t u r e s o

    f t h e

    8 0 5 1

    The 8051 , just as in the case of the ROM has the capability of accessing up 64KB of RAM for its RAM operations, if the on-chipRAM provision is not enough.

    In a summary of the memory features of the 8051, the figure below isused to illustrate memory features.

    I n p u

    t

    O u

    t p u

    t P o r t s o

    f t h e

    8 0 5 1

    Just as we have mention earlier the 8051 is a 40 pins IC. The figure below shows the pin out of the 8051.

    Input Output Ports of the 8051The pin outs on the 8051 are basically divided into 4 ports namely ;

    Port 0 (P0), Port 1(P1), Port 2 (P2), Port 3 (P4).

    These ports serves the function of input and output to themicrocontroller. Each of these ports are 8 bit wide and has specialfunction registers (P0,P1,P2,P3),which are addressable independently.

    PORT 0Port 0 has 8 pin out corresponding to its 8bits and pin 32 to pin 39 .Labeled as P0.0 to P0.7 in the above figure.

    This port has a dual function as it may serve as input ,output or evenused together. It can also be used as bi-directional low order addressand data bus for external memory.

    The 8051 is an active low IC, meaning that when a pin is to be used asan input a 1 must be written to that port and 0 when to be used as anoutput.

    Input Output Ports of the 8051Port 0, can be used as an address or data bus to connect to an externalmemory. When used as an address bus to an external memory , after the has been formed and latched into external circuit by the addressLatch Enable (ALE) Pulse, the bus is turned around to become a data

    bus, the port (port 0) will now rea d data from the ext ernal memory andmust be configured as an input so a logic 1 is automatically written bythe internal controllogic to all the port 0 latches.

    PORT 1Port 1 has 8 pin-outs just like port 0 and pins 1-8 labeled P1.0 to P1.7Basically port 1 can only be used for input and output functions to andfro external devices only. Hence it has no dual function although it is

    bidirectiona l in nature.

    PORT 2Port 2 may be used as an input or output port similar to the operationsof port 0. it has 8pin-outs corresponding to pins 21-28 and labeledP2.0 to P2.7.

  • 7/28/2019 overview of 8051

    5/7

    6/24/2013

    5

    Input Output Ports of the 8051This port has a dual function as it may serve as input ,output or evenused together. It can also be used as higher order address inconjunctionwith the port 0 when addressing external peripherals.

    The latch of the port 2 remains stable when external memory isaddressed as they do not have to be turned around for data input justas in the case of port 0. This is because the data bus is 8 bit and can beaccessed bythe lower order address port of port 0.

    PORT 3Port 3 is an input or output port similar to port 1. The port is also

    bidirectional ju st as any of the other 3 ports. Basically this port can beused for the input , output functions and also some special functions.

    Port 3 has 8 pin out corresponding to its 8bits and pin 10 to pin 17 .Labeled as P3.0 to P3.7 in the above figure.

    Input Output Ports of the 8051Other alternate functions of port 3 includes the following ashighlighted in the table below.

    other functions on the 8051SERIAL PORT: (P3.0,P3.1)The serial Port is a means in which the microcontroller communicateswith the outside world. It is called serial because the data bits will besent in a serial way over a single line.

    Remember a communication can be could be asynchronous or synchronous in nature. When Synchronous the receiver and send

    usually shares a clock to know when to read or write. While inAsynchronous transmission no clock signal is required. The 8051 aswell as all other microcontrollers utilizes the UART (UniversalAsynchronous Receiver Transmitter) for the serial communication .

    There are two pins available for the serial communication TXD,RXD. Normally T XD is used for t ransmitting seri al da ta, whi le the RXD isfor the receivingof the serial data

    other functions on the 8051

    INTERRUPT:Interrupt are mechanism which enables the microcontroller to respondto some events regardless of what its doing at that time. Each interruptchanges the program flow, interrupts it and after executing the interruptrouting it continues from that same point. Interrupt routines areactivatedby the occurrence of either an external or an internal event.

    The routine that deals with specific interrupt is called an Interruptservice Routine(ISR).

    The interrupt allows the 8051 to respond to asynchronous events(external or Internal )only when required. The 8051 has 5 interrupts , 3internal which can be from the timer (T0,T1), Serial Port (TXD,RXD)And the remaining two is generated external via the INT0 and INT1

    pins.

  • 7/28/2019 overview of 8051

    6/7

    6/24/2013

    6

    other functions on the 8051TIMER: (T0,T1):Some microcontroller application often require the counting of external events such as the frequency of a pulse train. Timer meanswhich can give the delay of particular time between some events. For instance the switching on and off a lighting bulb every 5 sec. Thistime delay can be achieved either by programming or hardware.

    The 8051 is embedded with 2 timers to achieve these delay. Twotimer pins are available, namely (P3.4) T0 and (P3.5) T1, by thesetimer we can give the delay of particular if we use these in timer mode.We can count external pulse at these pins if we use these pins incounter mode. These timers are 16-bits, which means can generatedelay by 0000h to FFFFh .

    WR (P3.6) is used to write to the external memory

    RD(P3.7)- is used to read for the external memory .

    other functions on the 8051So far we have identified the functions of 32 pins of the 40 pins on the8051 which corresponds to the ports 0,1,2,and 3.So what are the function(s) of the remaining pins. Observed theremaining pins are ; 9,18,19,20,29,30,31 and 40. Pins 29,30,31 aregrouped as the Bus control signal pin-outs. Basically they mostly usedwhen external peripheralsare interfaced onto the microcontroller.

    PSEN= (PIN 29) (Program Store Enable) this enables external program- code memory. Usually connected to the external ROMoutput.

    ALE(PIN 30) ( Address Latch Enable) used for the de-multiplexing theaddress and data bus when port 0 is used as the data bus and a low-

    byte of address bus.

    EA =(PIN 31) ( External Access) this is used to indicate whether anexternal or internal ROM is used. If set to high indicates internal and alow is used to execute programs from the external. That is why it isconnectedto ground when using an external Peripherals.

    other functions on the 8051Others pins used in interfacing / connecting external peripheralsincludes ; P3.6 and P3.7 on port 3.P3.6 WR is used to write to the external memory while theP3.7 RD- is used to read for the external memory .

    In summary

    When interfacing an external memory to the 8051, the following pinsare used WR, RD, PSEN,EA ,ALE . The figure below shows the8051 connected to an external memory .

    P o r t s a n

    d p

    i n s u s e

    d f o

    r e x

    t e r n a

    l I n t e r f a c e

  • 7/28/2019 overview of 8051

    7/7

    6/24/2013

    7

    P o r t s a n

    d p

    i n s u s e

    d f o r e x

    t e r n a

    l I n t e r f a c e

    Interfacing with a ROM

    Interfacing with a RAM Interfacing with a ROM and RAM together

    P o r t s a n

    d p

    i n s u s e

    d f o r e x

    t e r n a

    l I n t e r f a c e

    other functions on the 8051RESET (PIN 9): This is used to reset the 8051.

    CRYSTALS (PIN 18 , PIN 19 ) : is used to provide themicrocontroller the clock which is used to decide its speed and thesynchronization of its operations. For this clock signal to be generatedit requires crystal oscillators to be connected as shown below in order to generate the required frequency. A frequency range of 1MHZ to

    16MHZ is required for the operation of the 8051. Although 12MHZfrequencyis mostly used.

    other functions on the 8051GROUND (PIN 20): This is used as the GND and must be connectedto the ground.

    VCC(PIN 40 ) : is used as voltage source, which is +5Volts.