Download Microcontroller1

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
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.
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.
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 Microcontrollers are used to handle real time tasks as
they are severely dependent on several other components.
they are single programmed, self sufficient and task
oriented devices.
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)
Internal architecture of 8051
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.
PSW
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.
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.
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
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.
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
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.
Pin Diagram
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
RST
(RXD)P3.0
(TXD)P3.1
(INT0)P3.2
(INT1)P3.3
(T0)P3.4
(T1)P3.5
(WR)P3.6
(RD)P3.7
XTAL2
XTAL1
GND
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
8051
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
Vcc
P0.0(AD0)
P0.1(AD1)
P0.2(AD2)
P0.3(AD3)
P0.4(AD4)
P0.5(AD5)
P0.6(AD6)
P0.7(AD7)
EA/VPP
ALE/PROG
PSEN
P2.7(A15)
P2.6(A14)
P2.5(A13)
P2.4(A12)
P2.3(A11)
P2.2(A10)
P2.1(A9)
P2.0(A8)
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.