Beruflich Dokumente
Kultur Dokumente
Ajit Samasgikar
IT Department
D t t
B.V.B.College of Engg. & Tech., Hubli
Ajit Samasgikar
Syllabus
Unit
U i –I
•Introduction to microcontrollers
RISC & CISC CPU Architectures, Harvard & Von-Neumann CPU architecture.
The 8051 Architecture: Introduction,, 8051 Microcontroller Hardware,, Input/output
p p
Pins, Ports and Circuits External Memory, Counter and Timers, Serial Data Input /
Output, Interrupts 05 hrs
•Addressing Modes and Operations
I t d ti
Introduction, Add
Addressing
i modes,
d E t
External
l data
d t Moves,
M C d Memory,
Code M R d Only
Read O l
Data Moves / Indexed Addressing mode, PUSH and POP Opcodes, Data exchanges,
Example Programs; Byte level logical Operations, Bit level Logical Operations,
Rotate and Swapp Operations,
p Example
p Programs.
g Arithmetic Operations:
p Flags,
g
Incrementing and Decrementing, Addition, Subtraction, Multiplication and Division,
Decimal Arithmetic, Example Programs. 06
hrs
•Jump and Call Instructions
The JUMP and CALL Program range, Jumps, calls and Subroutines, Interrupts and
Returns, Example Problems.
05 hrs
Ajit Samasgikar
Unit – II
Unit
•Timer / Counter Programming in 8051
Programming 8051 Timers, Counter Programming, programming timers 0 and 1
in 8051 C. 06 hrs
•8051 Serial Communication
Basics of Serial Communication, 8051 connections to RS-232, 8051 Serial
communication Programming, Programming the second serial port, Serial port
programming in C. 07 hrs
Unit – III
• Interrupts Programming
8051 Interrupts, Programming Timer Interrupts, Programming External
Hardware Interrupts, Programming the Serial Communication Interrupts, Interrupt
P i it in
Priority i the
th 8051/52,
8051/52 Interrupt
I t t programming
i in
i C.
C 06 hrs
• 8051 Interfacing and Applications
Interfacing 8051 to LCD, Keyboard, parallel and serial ADC, DAC, Stepper
motor interfacing,
interfacing DC motor interfacing and PWM.
PWM 07 hrs
Ajit Samasgikar
Why do we need to learn
Mi
Microprocessors/controllers?
/ t ll ?
• The microprocessor is the core of computer
comp ter
systems.
• Nowadays many communication,
communication digital
entertainment, portable devices, are
controlled by them.
them
• A designer should know what types of
components he needs,
needs ways to reduce
production costs and product reliable.
Ajit Samasgikar
Different aspects of a
microprocessor/controller
Ajit Samasgikar
The necessary tools for a
microprocessor/controller
i / ll
Ajit Samasgikar
Microcontroller :
• A smaller computer
• On-chip RAM, ROM, I/O ports...
• Example:Motorola
Example:Motorola’ss 6811
6811, Intel’s
Intel s 8051
8051, Zilog’s
Zilog s Z8 and PIC 16X
Ajit Samasgikar
DIFFERENCE BETWEEN MICROCONTOLERS AND
MICROPROCESSORS
• MICROPROCESSOR • MICROCONTROLLER
• CPU consists of an ALU, PC, SP, some • CPU consists of ALU, PC, SP, registers,
working registers. RAM, ROM, interrupt circuits,parallel
Require to add RAM, ROM, memory & serial I/O, clock circuit.
decoders, counters & clock circuit.
• Used in real time applications to control
Prime use is to perform extensive data the environment or machines around it.
processing & handling
Have one or two multi
multi-byte
byte instructions
Have multi-byte instructions for
moving data from external memory to
CPU.
Have many bit handling instructions.
Have one or two types of bit handling
instructions
Ajit Samasgikar
DIFFERENCE BETWEEN MICROCONTOLERS AND
MICROPROCESSORS
• MICROPROCESSOR • MICROCONTROLLER
Ajit Samasgikar
Embedded System
Ajit Samasgikar
Three criteria in Choosing a Microcontroller
Ajit Samasgikar
Block Diagram
External interrupts
On-chip Timer/Counter
CPU
Bus Serial
4 I/O Ports
OSC Control Port
P0 P1 P2 P3 TxD RxD
Add
Address/Data
/D t
Ajit Samasgikar
FEATURES OF 8051 ARCHITECTURE:
Ajit Samasgikar
9 32 input/output pins arranged as four 8 bit port: P0-P3
9 2 sixteen bit timers/counters: T0 & T1
9 Full duplex serial data receiver/ transmitter:SBUF
9 Control registers: TCON,
TCON TMOD,
TMOD SCON,
SCON PCON,
PCON IP
IP, IE
9 2 external & 3 internal interrupt sources.
9 Oscillator & clock circuits.
Ajit Samasgikar
ALU PSW SFRs Latch Port0
RAM
A B
Latch Port1
8051 has Harvard architecture which uses the same address in different
memories for code and data.
INTERNAL RAM :
Bit addressable area of 16 bytes occupying RAM byte addresses 20H to 2FH,
forming a total of 128 addressable bits.
A general purpose RAM area above bit area from 30H to 7FH addressable as
bytes
Ajit Samasgikar
Internal RAM
Byte Address Byte Address
1F R7 7F
1E R6
1D R5
1C R4
Bank 3 1B R3
1A R2
19 R1
18 R0
17 R7
16 R6
15 R5
14 R4
Bank 2 13 R3
12 R2
11 R1 Byte Bit
10 R0
0F R7 Address Addresses
0E R6 7F 78
2F
0D R5 77 70
2E
0C R4 6F 68
2D
0C R4 67 68
2C
Bank 1 0B R3 2B 5F 58
0A R2 57 50
2A
09 R1 4F 48
29
08 R0 47 40
28
07 R7 3F 38
27
06 R6 37 30
26
05 R5 2F 28
25
04 R4 27 20
24
Bank 0 03 R3 23 1F 18
02 R2 17 10
22
01 R1 0F 08
21
00 R0 07 00
20 30
7 0
Working Registers Bit Addressable General Purpose
Ajit Samasgikar
STACK & STACK POINTER
Ajit Samasgikar
SPECIAL FUNCTION REGISTERS:
Ajit Samasgikar
• SCON SERIAL PORT CONTROL 98
• SBUF SERIAL PORT DATA BUFFER 99
• SP STACK POINTER 81
• TMOD TIMER / COUNTER MODE CONTROL 89
• TCON TIMER / COUNTER CONTROL 88
• TL0 TIMER 0 LOW BYTE 8A
• TH0 TIMER 0 HIGH BYTE 8C
• TL1 TIMER 1 LOW BYTE 8B
• TH1 TIMER 1 HIGH BYTE 8D
Ajit Samasgikar
INTERNAL ROM
9 data and program memories in 8051 can be entirely
different physical memory entities, with the same address
ranges
9 occupies code address space 0000h to 0fffh, which is
the area where pprogram
g code resides
9 if the program address exceeds 0fffh, the code byte is
fetched from external program memory
Ajit Samasgikar
Addressing Modes
Ajit Samasgikar
8051 DATA ADDRESSING MODES
• 1. Register
1
• 2. Direct
• 3. Register-Indirect
Register Indirect
• 4. Immediate Data
Ajit Samasgikar
1.REGISTER ADDRESSING
• 8051 has FOUR banks of registers.
• Onlyy one bank visible at any
y one time.
• PSW register is used to select the bank.
• g
These 32 registers appear
pp in on chip
p RAM
memory(00-1FH)
Ajit Samasgikar
Byte Addressable Registers
Registers.
Register addressing consists of an opcode, the
operand,
p , which specifies
p which register
g to use,, is p
part of
the opcode byte.
eg. ADD A,Rn
Register Addressing
Typical example of accessing the registers are,
eg MOV R0
eg. R0,A
A ; move the accumulator into R0
Ajit Samasgikar
2 DIRECT ADDRESSING
2.DIRECT
•Direct addressing can access any on chip variable or H/W.
•Operand specifies the location in on-chip memory to use.
•The opcode is followed by a byte operand which specifies the direct
address to use
•All I/O ports and special function registers are assigned addresses
between 80H and FFH
•They are also direct addressable
addressable.
eg. MOV A,80H ; move data from PORT 0 to accumulator.
Ajit Samasgikar
3 IMMEDIATE ADDRESSING
3.
•In this operand follows the opcode which is constant.
•In 8051 assembly language , immediate addressing is signified by
using the # prefix.
•eg. MOV A,#12H
A #12H ; lloads
d 12 H iinto
t th
the accumulator.
l t
Ajit Samasgikar
4. REGISTER INDIRECT
ADDRESSING
• It is used to calculate the address of variable
in RAM while the program is running.
• R0 and d R1 off each
h register
i t b bank
k can actt as
index or pointer registers.
• The opcode specifies which register is used
to generate the Effective address for the
operand.
Ajit Samasgikar
• In 8051 assembly language, this addressing
mode uses the p prefix ‘ @
@’
eg.
MOV A,#@R0
A #@R0
This means load the accumulator with the
contents off the
h memory location
l i specified
ifi d
by R0
Ajit Samasgikar
Flags & the Program status Word(PSW)
CY AC F0 RS1 RS0 OV - P
Bit Symbol
y Function
7 CY Carry flag; used in arithmetic, jump, rotate, &
Boolean instruction
6 AC Auxiliary Carry flag; used for BCD arithmetic
5 FO User flag 0
Ajit Samasgikar
4. RS1 Register bank select bit 1
3
3. RS0 Register bank select bit 0
RS1 RS0
0 0 Bank 0
0 1 Bank 1
1 0 Bank 2
1 1 Bank 3
2. OV Overflow flag; used in arithmetic
instructions
1. - Reserved for future use.
0. P Parity flag
Ajit Samasgikar
The 8051 oscillator & clock
• Pins XTAL1 & XTAL2 are provided for
connecting a resonant network to form oscillator.
• Crystal freq. is the basic internal clock freq. Of
micro controller.
• 8051 can run at specified min. & max.
frequencies, typically 1 MHz to 16MHz.
Ajit Samasgikar
Oscillator Circuit & Timing
Ajit Samasgikar