2. Microcontroller
On-chip computer
Micro-Processor is a computer’s CPU
To make a complete computer, following components have to be
added:
1. RAM
2. ROM
3. I/O devices
4.Clock generator
5. Interrupt controller
Micro-controller contains all these components along with CPU in a
single chip.
Example: Mobile Phone, Television Remote, Smart DVD players, etc.
3.
4. Features of Microcontroller
Compact than microprocessor system.
Fixed amount of Internal RAM and ROM memory
Suitable for Special purpose applications.
Mostly used for only one task/application.
Program for the task is burned into ROM.
Low Power consumption
Micro-controller based system is cheaper than microprocessor.
5. Micro-Processor Micro -controller
CPU on a single integrated circuit (IC). Has a CPU, RAM, ROM, I/O devices, etc.
General purpose systems Used in automatically controlled devices.
Computational capacity of microprocessor is very high. Less computational capacity
Can perform numerous tasks. Can perform single or very few tasks.
The overall cost of a system built using a microprocessor is
high. This is because of the requirement of external
components.
Cost of a system built using a microcontroller is less as
all the components are readily available.
Power consumption and dissipation is high because of the
external devices.
Power consumption is less.
The clock frequency is very high usually in the order of GHz. Clock frequency is less usually in the order of MHz.
Have few bit manipulation instructions Bit manipulation is powerful and widely used feature
in microcontrollers.
Generally microprocessors are not used in real time systems as
they are severely dependent on several other components.
Microcontrollers are used to handle real time tasks as
they are single programmed, self sufficient and task
oriented devices.
6.
7. 8051
8 bit Micro-controller.
CPU of 8051 can access only 8 bit at a time.
Data longer than 8 bit have to be broken down into 8 bit pieces.
8 bit data bus
8 bit microcontroller means 8 bit data can travel on the data bus
16 bit address bus. Can address 64KB
4 I/O ports, each ports are 8 bits wide.
IC contains 40 pins
8051 is based on harvard architecture
Separate Code and data memory address space.
Can use same memory address for code(ROM) and data (RAM)
11. 8051 CPU
CPU contains two math registers
A- Accumulators.
B –used for Multiplication and division.
Accessed by their name or address E0 and F0 respectively.
A and B are both byte and bit addressable registers.
Each bit in the register can be addressed individually.
13. ROM and PC
ROM contains code.
Internal ROM address ranges from 0000 to 0FFF
16 bit register PC holds the address of next instruction in ROM
PC automatically increments or updated.
Address range above 0FFFH address external ROM.
Code byte can also be exclusively fetched from external ROM
By setting the EA pin in the processor.
PC is the only register which does not have internal address.
14. DPTR
16 bit register.
Contains 2 8-bit register DPL and DPH
Used for storing 16bit values
Used to access external code memory or external data memory.
MOV DPTR, #data16
; setup DPTR with 16bit ext address
MOVX A, @DPTR
; copy mem[DPTR] to A
DPTR is useful for string operations and Look-Up-Table (LUT)
operations.
15. RAM
128 bytes of RAM are used to store data.
Address range from 00 to 7F.
RAM contains
1. 4 register banks : 00 to 1F
2.Bit addressable memory : 20 to 2F ( 00 to 7F)
3. General purpose memory area : 30 to 7F
Each register bank contain 8 registers.
R0, R1,R2,R3,…R7
16. Register Banks
There are four register bank in the RAM 00 to 1F memory are.
RAM 32 bytes are allocated for these register banks.
RAM address range for register banks are:
B0 : 00 to 07
B1: 08 to 0F
B2: 10 to 17
B3: 18 to 1F
In a program we can access only one register bank at a time.
By default R0,R1,…in program are corresponding to register Bank 0.
To select other register bank, PSW 3rd and 4th bit have to set accordingly.
17. Stack Pointer
8 bit register.
Stack area is in internal RAM
Stack grows upwards (from low memory to high memory).
During PUSH, first SP is incremented and then copy the data.
In the POP operation, initially copy the data and then decrement the SP.
On power-up, SP points to 07H.
Register banks 2,3,4 (08H to 1FH) form the default stack area.
Bit addressable area 20 to 2F must not be used for stack.
Stack can be relocated by setting SP to the upper memory area in 30H to 7FH.
mov SP, #30H
18. Special Function Registers
Four 8 bit I/O port registers : P0,P1,P2,P3
Two 16 bit Timer register T0 and T1
Each consist of two 8 bit registers TL0 ,TH0 and TL1, TH1
One 8 bit Timer/counter control register TCON
One 8 bit Timer/counter mode control register TMON
One 8 bit Serial port control register SCON
One 8 bit Serial data buffer register SBUF
One 8 bit Interrupt priority register IP
One 8 bit Interrupt Enable control register IE
One 8 bit Power control register.
21. Pins of 8051
Vcc(pin 40):
Vcc provides supply voltage to the chip.
The voltage source is +5V.
GND(pin 20):ground
XTAL1 and XTAL2(pins 19,18)
These 2 pins provide external clock using a quartz crystal
oscillator by inverse piezo- electric effect.