8051 microcontroller is designed by Intel in 1981 . It is an 8-bit microcntroller . It is built with 40 pin DIP ( dual package ), 4kb of ROM storage and 128 bytes of RAM storage 2 , 16-bit timers . It consists of are four parallel 8-bit ports , Which are programmable as well as addressable as per the requirement.

 The necessary tools for a Microcontroller

  • CPU: Central Processing Unit
  • I/O: Input /Output
  • Bus: Address bus & Data bus
  • Memory: RAM & ROM
  • Timer
  • Interrupt
  • Serial Port
  • Parallel Port


Microprocessors

  • CPU for Computers
  • No RAM, ROM, I/O on CPU chip itself
  • Example: Intel's x86, Motorola’s 680x0


What is Microcontroller?



  • A smaller computer
  • On-chip RAM, ROM, I/O ports...
  • Example: Motorola’s 6811, Intel’s 8051, Zilog’s Z8 and PIC






Microprocessor vs. Microcontroller

                                 Microprocessor                                             Microcontroller









Microcontrollers for Embedded Systems

Home

Appliances, intercom, telephones, security systems, garage door openers, answering machines, fax machines, home computers, TVs, cable TV tuner, VCR, camcorder, remote controls, video games, cellular phones, musical instruments, sewing machines, lighting control, paging, camera, pinball machines, toys, exercise equipment etc.

Office

Telephones, computers, security systems, fax machines, microwave, copier, laser printer, color printer, paging etc.

Auto

Engine control, air bag, ABS, instrumentation, security system, transmission control, entertainment, climate control, cellular phone, keyless entry


Choosing a Microcontroller

  • 8-bit microcontrollers

  1. Motorola’s 6811
  2. Intel’s 8051
  3. Zilog’s Z8
  4. Microchip’s PIC

  • There are also 16-bit and 32-bit microcontrollers made by various chip makers

1. Meeting the computing needs of the task at hand efficiently and cost effectively

  • Speed
  • Packaging
  • Power consumption
  • The amount of RAM and ROM on chip
  • The number of I/O pins and the timer on chip
  • How easy to upgrade to higher performance or lower power-consumption versions
  • Cost per unit

2.     Availability of software development tools, such as  compilers, assemblers, and debuggers

3.     Wide availability and reliable sources of the microcontroller

The 8051 family has the largest number of diversified (multiple source) suppliers

  • Intel (original)
  • Atmel
  • Philips/Signetics
  • AMD
  • Infineon (formerly Siemens)
  • Dallas Semiconductor/Maxim


Salient Features

  1. 8 bit microcontroller originally developed by Intel in 1980. 
  2. High-performance CMOS Technology.
  3. 40 pin DIP IC
  4. Address bus is of 16 bit & data bus is of 8 bit.
  5. 4K bytes internal ROM (Program memory).
  6. 128 bytes internal RAM (Data memory).
  7. It has four 8 bit ports, total 32 I/O lines.  
  8. Two 16-bit timers (T0 & T1).
  9. Serial interface Communication.
  10.  64K external code & data memory space.
  11. 8051 implements a separate memory space for programs (code) and data.
  12.  Operating  frequency is 24MHz-33MHz and it contains On-chip clock oscillator
  13.  +5V Regulated DC power supply is required to operate .
  14.   Full duplex UART.
  15.  8051 has 21 special function registers (SFRs).

 

 8051 Family

  •  The 8051 is a subset of the 8052
  • The 8031 is a ROM-less 8051




Block Diagram Of Microcontroller 8051



  • 8-bit controller
  • Data larger than 8-bit has to be broken into 8-bit pieces to be processed by the CPU
  • 8051 is subset of 8052. i.e. prgs. Written for 8051 will run on 8052 but reverse is not true.
  • To use 8031 we have to add external ROM to it bcoz it is ROM-less


Program Counter

  • Points to the address of next instruction to be executed from ROM
  • 16 bit register
  • i.e. 8051 can access program address from 0000H to FFFFH, a total of 64 KB of code.
  • Initially PC has 0000H (i.e. when mc is powered up PC has a value 0000H in it)
  • ORG inst. Is used to initialize the PC.
  • PC is incremented after each inst.


8051  Pin diagram






XTAL2 and XTAL1   (18 and 19 pins)

  • The 8051 has an on-chip oscillator but requires an external clock to run it
  • A quartz crystal oscillator is connected to inputs XTAL1 (pin19) and XTAL2 (pin18)
  • The quartz crystal oscillator also needs two capacitors of 30 pF value




  • If you use a frequency source other than a crystal oscillator, such as a TTL oscillator:
  • It will be connected to XTAL1
  • XTAL2 is left unconnected


  • The speed of 8051 refers to the maximum oscillator frequency connected to XTAL.
  • We can observe the frequency on the XTAL2 pin using the oscilloscope.

RST (Pin 9)

  • RESET pin is an input and is active high (normally low)
  • Upon applying a high pulse to this pin, the microcontroller will reset and terminate all activities
  • This is often referred to as a power-on reset
  • Activating a power-on reset will cause all values in the registers to be lost

EA(pin 31):external access                         

  • There is no on-chip ROM in 8031 and 8032 .
  •  The EA pin is connected to GND to indicate the  code is stored externally.
  •  PSEN & ALE are used for external ROM.
  •  For 8051, EA pin is connected to Vcc.
  •  “      ” means active low                                                                                                         
  •  EA  “external access’’, is an input pin and must be connected to Vcc or GND
  • The 8051 family members all come with on-chip ROM to store programs and also have an external code and data memory.
  • Normally EA pin is connected to Vcc
  • EA pin must be connected to GND to indicate that the code or data is stored externally


PSEN (Pin 29)

  • PSEN, “program store enable’’, is an output pin
  •  This pin is connected to the OE pin of the external memory.
  •  For External Code Memory, PSEN = 0
  •  For External Data Memory, PSEN = 1

 ALE(pin 30):

  •  Address Latch Enable
  • It is an output pin and is active high.
  • 8051 port 0 provides both address and data.
  • The ALE pin is used for de-multiplexing the address and data by connecting to the G pin of the 74LS373 latch.


PARALLEL I /O PORTS Structure

  • The four 8-bit I/O ports P0, P1, P2 and P3 each uses 8 pins.
  • All the ports upon RESET are configured as output, ready to be used as input ports by the external device. 
  • In order to make them input, all the ports must be set  i.e a high bit  must be sent to all the port pins.
  •  This is normally done by the instruction  “SETB”.

         Ex: MOV A,#0FFH         ;  A =  FF 

                MOV P0,A                ; make P0 an input port


Port 0

  • Port 0  is an 8-bit I/O port with dual purpose.
  • If external memory is used, these port pins are used for address/data (AD0-AD7)
  • Otherwise all bits of the port are either input or output.
  • Unlike other ports, Port 0  is not provided with pull-up resistors internally
  • So for PORT0 pull-up resistors of nearly 10k are to be connected externally as shown in the fig.2


  • Port 0 is also designated as AD0-AD7.
  • When connecting an 8051 to an external memory, port 0 provides both address and data.
  • The 8051 multiplexes address and data through port 0 to save pins.
  •  ALE indicates if P0 has address or data.
  • When ALE=0, it provides data D0-D7
  • When ALE=1, it has address A0-A7



Port 1 and Port 2

  • In 8051-based systems with no external memory connection:
  • Both P1 and P2 are used as simple I/O.
  • In 8051-based systems with external memory connections:
  • Port 2 must be used along with P0 to provide the 16-bit address for the external memory.
  • P0 provides the lower 8 bits via A0 – A7.
  • P2 is used for the upper 8 bits of the 16-bit address, designated as A8 – A15, and it cannot be used for I/O.



Port 3

  • Port3 is also an 8-bit parallel port  with dual function.( pins 10 to 17). 
  • The port pins can  be used  for I/O operations    as well as for  control  operations. 
  • Upon reset  port 3 is configured as an output port .
  •  If the port is to be used as input port, all the port bits must be made high by sending FF to the port. 
  • For ex,   MOV A, #0FFH         ; A= FF hex

                    MOV P3, A                ; make P3 an input port by writing all 1’s to it

                    


   

   8051 Memory Space

Memory Organization 128 Byte RAM


  • There are 128 bytes of RAM in the 8051.
  • Assigned addresses 00 to 7FH
  • The 128 bytes are divided into 3 different groups as follows:
  • A total of 32 bytes from locations 00 to 1F hex are set aside for register banks and the stack.
  • A total of 16 bytes from locations 20H to 2FH are set aside for bit-addressable read/write memory.
  • A total of 80 bytes from locations 30H to 7FH are used for read and write storage, called scratch pad.



RAM address range

  • 128 bytes = 27 byte                                                                                                                       (that means last 7 bits can be changed)

                             7   6   5   4   3   2   1   0

      int. add.       0   0   0   0   0   0   0   0    (00H)

      final add.     0    1   1   1   1   1   1   1    (7FH)

This procedure is called memory mapping


8051 RAM with  addresses



8051 Register Bank Structure



8051 Register Banks with address



4 KB ROM

  • It is available for program storage
  • Used for permanent data storage
  • Volatile memory (data does not lost after power failure)
  • This ROM is also called program memory or code memory. 
  • 4 KB = 22 KB = 22 *  210 B   (1KB=210 B)

                              = 212 bytes   (that means last 12 bits can be changed)

14   13   12   11   10   9   8   7   6   5   4   3   2   1   0

  0     0     0     0      0     0    0    0   0   0   0   0   0   0   0   0 (0000H)

  0     0     0     0      1     1    1    1   1   1   1   1   1   1   1   1 (0FFFH)

i.e. add. Range of PC is 0000H to 0FFFH where we can save program




A Register (Accumulator)

One of the data should be in acc. & other may be in memory or register. Result of operation is stored in acc. It is 8-bit



B Register

Multiplication and division can be performed only upon numbers stored in the A and B registers. It is also 8-bit. It is used during multiply (MUL AB) & division (DIV AB) operation,



Data Pointer Register (DPTR)

It consists of two separate registers: DPH (Data Pointer High) and (Data Pointer Low). 

For this reason it may be treated as a 16-bit register or as two independent 8-bit registers. 

Their 16 bits are primarily used for external memory addressing. Besides, the DPTR Register is usually used for storing data and intermediate results.



Stack Pointer (SP) Register

A value stored in the Stack Pointer points to the first free stack address and permits stack availability. 

Stack pushes increment the value in the Stack Pointer by 1. Likewise, stack pops decrement its value by 1. Upon any reset and power-on, the value 7 is stored in the Stack Pointer, which means that the space of RAM reserved for the stack starts at this location.



Interrupt Priority (IP)

 Used to indicate the relative priority of each interrupt.

An interrupt may be of low(0) or high (1) priority


Interrupt Enable (IE)

  • Used to enable or disable the specific interrupts.
  • Bits fro 0-6 of register EI are used to enable/disable the particular interrupts
  • Where as MSB is used to E/D all the interupts.
  • Means MSB is a master bit


Program Status Word [PSW]



  • Used to indicate arithmetic condition of Accumulator
  • Flag register in 8051 is called PSW
  • 8-bit register
  • Only 6-bits are used in 8051
  • 2 unused bits are user definable flags
  • Do-Parity bit: For even result of acc., P=1, And for odd result of acc., P=0. It is mainly used during data transmit & receive via serial communication
  • D1-for future version of Mc
  • D2-overflow: OV is set to 1 when result of a signed no. operation is too large, causing the high order bit to overflow into the sign bit. i.e. OV is only used to detect errors in signed arithmetic operations.
  • D3 & D4: Resistor bank select as shown in diagram in previous slide.

        For selecting Bank 1 we will use:

           SET B PSW 0.3 (means RS0=1)

           CLR PSW 0.4 (means RS1=0)      initially by default Bank0 is selected

  •  D5 : FO   Available to user for general purpose
  • D6: Auxiliary carry Flag: when carry is generated from D3 to D4 it is set to 1. Used in BCD arithmetic

                         1 1 1 1

                  0 0 0 0 1 1 1 0

                  0 1 0 1 1 0 1 0

                  0 1 1 0 1 0 0 0 

  • D7 : Carry flag: When a carry is generated it is set to 1

  

  •   8051 Stack
  • The stack is a section of RAM used by the CPU to store information temporarily.

  1. This information could be data or an address
  2. It use LIFO principle


  • The register used to access the stack is called the SP (stack pointer) register

  1. The stack pointer in the 8051 is only 8 bit wide, which means that it can take value of 00 to FFH
  2. When the 8051 is powered up, the SP register contains value 07
  3. RAM location 08 is the first location begin used for the stack by the 8051

  • The storing of a CPU register in the stack is called a PUSH

  1. SP is pointing to the last used location of the stack
  2. As we push data onto the stack, the SP is incremented by one
  3. This is different from many microprocessors


  • Loading the contents of the stack back into a CPU register is called a POP

  1. With every pop, the top byte of the stack is copied to the register specified by the instruction and the stack pointer is decremented once    


PLC

how to draw Ladder Diagram ?
 
Different Programming Languages of PLC 
 
Memory Structure of PLC?
 
PLC Input and Output Modules:
 
 How to draw Ladder Diagram ?
 
How to Read Ladder Logic? 
 
What is SCADA? Difference between DCS and SCADA
 
AVS 
 
What is PLASMA TV ?
 
What is difference between OLED vs LED, LCD What is the best TV 
 
Digital Television - Transmission and Reception 
 
Explain Digital Video , Compression Techniques and Standards 
 
Differences between LED-backlit and Backlit  LCD displays 
 
what is color Television? 
 
what is TV? 
How are the Microphone ? Types