Saturday 27 August 2011

8051 ARCHITECTURE

                                         8051(µCONTROLLER)
 The very first question teacher ask , in the 1st Lecture of  8051 class is that :
     what is difference between microcontroller & microprocessor ?
  what answer they expect from the students :
     microprocessors has only CPU & contains no RAM, no ROM , no I/O ports on the chip
      itself while microcontrollers has CPU in addition to a Fixed amount of RAM ,ROM, I/O ports and timers on a SINGLE CHIP.
   but this answer is not true always. 


APPLICATION areas:
               TVs,Fax machine,Telephones,remote controls,Video games,Cellular phones,
                musical instruments,Camera,printers,Engine control,Air bags,instrumentation
                Security system,Transmission control,Climate control and off course my
                favourite application ROBOTICS.
      these applications are sometimes referred as EMBEDDED SYSTEM products.

COMPANIES providing microcontrollers :
               INTEL                                                         www.intel.com
               ATMEL                                                        www.atmel.com
               PHILIPS                                                       www.semiconductors.philips.com
               INFINEON                                                 www.infineon.com
               DALLAS Semi/MAXIM                              www.maxim-ic.com                ....and many more.

INSIDE the microcontroller :
                                                Take an example of university , they have separate section for 
        MANAGING accounting,admission,examination,sports,research & development ,training
        & placement ,students affair etc , In the same way microcontroller has different section to perform
        dedicated operation.
       
         As you can see the building blocks of microcontroller :

  •          suppose you are watching television ,after 15 minute your MOM ask to come to        dining hall for dinner . So watching television is the program running in microcontroller & calling by Ur mom is external signal interfering Ur watching/program called Interrupt.  e.g   activate an alarm in a BLAST FURNACE if temperature exceed  480K.
  • program which is running in microcontroller  is stored in memory called ROM .
  • we need some additional memory for storing data called RAM - this memory is divided into several parts based on what type of data we want to use e.g register bank , stack , bit-addressable memory,scratch-pad ,SFR(special function registers).
  • As name implies its something related to TIME . FUNCTION: 1.DELAY 2.as COUNTER 3.PWM control 
  • CPU manage all the functional blocks.
  • OSCillator provides clock pulse to microcontroller.
  • BUS control - address bus , data bus ,control bus
  • This is most important part of microcontroller .It is for taking i/p and giving  o/p .Each port is like a pipe having 8 wires inside it  isolated from  each other.                                                                                                   


you can use the whole pipe at a time called byte(8 bit) use. In the byte transfer all 8 wires of the cylinder are active. Now suppose we want to use only red & yellow wire of the pipe ,i.e you want 
to use only 2 wire(2 bit) ,it is called bit wise transfer of data.
There are 4 such cylinder (port) in microcontroller i.e each has 8 pins so total 4*8=32 I/O pins.

  • Serial port As its name implies it is also some kind of port having only 2wires.

There are 2 pins for serial  pins : 1.for transmitting the data 2.for receive data.e.g mouth-TxD ,ear-RxD  ?


features of 8051-  ROM-4kb   RAM-128bytes   TIMER-2   I/Opins-32  Serial port 1    INTERRUPT 6

8051 family members :  8052 ,8031(no ROM)

MAIN DISCUSSION :
now i will explain the pin connection of 8051 .Every successful programmers in the field of ROBOTICS ,EMBEDDED SYSTEM ,ROCKET,MISSILES,SATELLITE,NUCLEAR POWER PLANT etc   has good knowledge of hardware interconnections.In such fields you must have knowledge of how program interacts with hardware and environment.

  PIN DESCRIPTION :    Real story starts now :
         
                     1. VCC : It gives power to 8051 .The voltage source is +5V
              
                     2.GND : Pin 20 is grounded.

                     3.XTAL 1 & XTAL 2 : These 2 pins is connected to crystal. This crystal is used to give clock pulse to 8051. 8051 has on-chip oscillator but require an external clock to run it. In the very first article ,i told you how two capacitor are connected with two pins.
             the maximum external frequency always <= internal oscillator on-chip frequency.
 suppose 8051 chip has internal oscillator frequency 20 MHZ ,so we can connect 11.0592 MHZ
, 18 MHZ but we can't give 24 MHZ as an external source.
      note- to observe the crystal frequency you need to connect Ur oscilloscope to XTAL2 and if you  want to use another source for injecting frequency  connect it with XTAL 1 & left  XTAL 2 as it is .SPEED of 8051 depend on this frequency.    


              4.RST : pin 9 is called power-on reset .giving high pulse to this pin terminate all activities of 8051. when someone says 8051 has reset  ,it means the control is being transferred  to starting address & all data is lost which was in registers before reset .it is done by  setting the PC to all 0's.
   INTEL manual says :"To ensure a valid reset ,the reset  pin must be held high long enough to allow the oscillator to start plus two machine cycle"
                        5. EA(bar) : "External access" . some 8051 family members don't have on-chip ROM for program storage e.g 8031,8032 etc.
                                     This INPUT pin is used to give signal to CPU  whether code is stored externally or internally.
                                   31 pin to +5V - means program code is stored in on-chip ROM
                        31 pin to GND-means program code is stored in EXTERNAL ROM.
      31 pin MUST be connected ,it can be left unconnected


                 6.PSEN(bar) : "program store enable " .this is o/p pin for 8031 based systems where code is stored externally and this pin is connected to pin of external ROM. 


                  7. ALE : "address latch enable"  . PORT 0 of microcontroller is used to access data as well as address .So there must be something that indicates whether this port's pins is used as a data or address . this  output pin is designed for this purpose only.In order to save pin PORTS  are designed so.It is active high(ie if ALE=1 it indicates address ) 


                         8.Ports 0,1,2 and 3
P0: It is used for both data and address.This is distinguish by ALE as we saw before.this port is different then other ports because here we externally connect PULL-UP RESISTERS to pins of port 0 as shown in diagram :
   The pins of PO port MUST be connected to 10K -ohm PULL-UP RESISTERS , this is due to fact that P0 is an open drain unlike P1,P2 and P3( they already have this internally). .
P1 & P2 : .Simple input / output pins.

  •   P2 is used along with P0 to provide 16 bit address for the external memory.P0 provides the lower 8 bits of address(A0-A7) while P2 provides next 8 bits(A8-A15) of address

P3 :  These pins generally  used for providing some extremely important signals  signals
                    {  P3.0 & P3.1 }  <--  used for serial communication                     RxD , TxD
                     { P3.2 & P3.3 }  <-- used for external interrupts                            INT0(bar),INT1(bar)
                     { P3.4 & P3.5 }  <-- are set aside for TIMERS                               T0 , T1
                    { P3.6 & P3.7 }  <--  used to provide read & write signals                WR(bar),RD(bar)
                                                          to an external memory       
            these pins may be used for I/O operation .

                     
       ACTION just after RESET button is pressed


 .activating the power-on reset  will cause all values in registers to be lost.
 .It set the  program counter(PC) to 0000
 .CPU shift the control to address 0000
        REGISTER                RESET VALUE(in hex)
                   PC                                                     0000
         DPTR                             0000
                  ACC                                                       00
                  PSW                                                       00
                  SP                                                           07
                  B                                                              00
                P0 - P3                                                      FF

    MACHINE CYCLE vs CRYSTAL FREQUENCY


 ADD A,R1 ; Suppose this is  an instruction which CPU is going to execute .Execution time of     this instruction is measured through MC(machine cycle) . Now suppose someone says this instruction needs 2 machine cycle to execute . Q. what is time taken by CPU to execute it ? 


 believe me if you are capable of understanding this question then only you can understand  the concept of machine cycle & its related term.So first read the question 4 or 5 times .then only see the next section.


Clocks Per Machine Cycle(MC) for various 8051


                       CHIP MAKER                                            CLOCK PER MACHINE CYCLE
                    AT89C51/52(Atmel)                                                                 12
                    P89C54X2(philips)                                                                     6
                    DS89C4x0(dallas semiconductor)                                           1
        
The answer to the previous question leads to  another question Q.What is the crystal frequency you are injecting to this 8051 ? now suppose I am using crystal frequency of 22 MHZ . Now again you will ask Q.what is clock per MC value for the given 8051? 

now you are in position to give answer to the question.


Assume i am using  P89C54X2(philips)  microcontroller ,
   
                               ( 1/crystal_freq ) =1/22 =45.45 ns
       => so in one machine cycle  (45.45 * 6)=272.7 ns
       => so to execute that instruction 2MC=2*272.7 =545.4 ns Ans.


I have only revealed  < 2% concept about microcontroller , it was necessary because next post will be related to "C programming in robotics ,embedded application" where i will use some terms which i have explained in this section.





any suggestion about what you would like to see in the next article or to highlight errors in this articles or for any doubt please drop a line in this column...
                               or   contact : aies.hsprofessionals@gmail.com





upcoming article:

  • How to write a C program for your ROBOT ,DISPLAY DRIVERS & EMBEDDED SYSTEM
  • Make your LINE FOLLOWER ROBOT  ready in just 2 Hr.
  • Wireless control of your ROBOT via PC using TX433 & RX433.
  • Wireless communication between two or more ROBOT.
  • Physics behind TOUCH PAD DISPLAY.
  • Use that TOUCH PAD to remotely control ( wireless control over range 400 ft ,8kbps,434MHZ)             your ROBOT .
  • Discussion on DIGITAL IMAGE PROCESSING and INTERFACING CAMERA      with your  kit and your laptop.                











No comments:

Post a Comment

Note: only a member of this blog may post a comment.