Micro-Controller 8051
Micro-Controller 8051
Micro-Controller 8051
Overview
주식회사 H.I
시스템
MCS-51 Family Overview
80C51 Family Products
Pin Compatible
Internal Memory
DEVICE Timer Interrupt
Program Memory Data Memory
MicroProcessor Part II 2
MCS-51 Family Overview
Architectural Structure of the 8051 Family
FREQUENCY REFERENCE COUNTERS
CPU
Part Contents
Interrupt Control Ext / Internal Interrupts, Masking, Priority
Central Processing Unit Arithmetic / Logical Operation , Control
Internal Program Memory
ROM
4KB or 8KB : ROM ( = 805X ), EPROM ( = 875X )
RAM Internal Data Memory
4 x 8bit I/O port 4Byte I/O port ( P0 ~ P3 )
Serial Port Rcv/Snd 1 bit data.
Controller - Periodic Operation
Timer / Counter Event Counting, Check PulseWidth
Send periodic Interrupt to CPU
PSEN
External Program Control Signal
(Program Strobe Enable )
ALE (Address Latch Enable) Separate Address & Data
0V : Read PRG from External Memory
EA (External Access)
5V : Read PRG from Internal Memory
RST ( ReSeT) Reset port
MicroProcessor Part II 4
MCS-51 Family Overview
Main Features of 8051
Part Function
Arithmetic Operation.
Computation
Logical Operation
Data – External Memory 64KB , Internal Memory 128B
Memory Size
PGM – External Memory 64KB , Internal Memory 4KB
Parallel I/O port – 32 ( 4 x 8 Bit )
Communication
Serial I/O port – Full Duplex UART
2 x 16-Bit Timer , Clock Generator
Etc
5 Interrupts
MicroProcessor Part II 5
MCS-51 Family Overview
External Pin Description
P0.7 AD7
P0.6 AD6
P0.5 AD5
P0.4 AD4 Address/Data Bus
P0.3 AD3
P0.2 AD2
Bidirection I/O Port
P0.1 AD1
P0.0 AD0
/PSEN
P1.7
ALE P1.6
P1.5
/EA P1.4
P1.3 Bidirection I/O Port
/RST P1.2
P1.1
P1.0
RD P3.7 P2.7 A15
WR P3.6 P2.6 A14
T1 P3.5 P2.5 A13
Bidirection T0 P3.4 P2.4
INT1 P3.3 P2.3
A12 Address Bus
I/O Port A11
INT0 P3.2 P2.2 A10 Bidirection I/O Port
TXD P3.1 P2.1 A9
RXD P3.0 P2.0 A8
MicroProcessor Part II 6
MCS-51 Family Overview
Executing From External Program Memory
Timing
CLK
1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4
ALE
/PSEN
PORT2
PORT0
LATCH
Bus Cycle
MicroProcessor Part II 7
MCS-51 Family Overview
Executing From External Program Memory
Structure
DATA(AD7~AD0)
P1 P0 EPROM
8 /EA A7~A0
0 LATCH
5 Lower Addr.
1 ALE Addr
Upper Addr. (A15~A8)
P3 P2
/OE
/PSEN
MicroProcessor Part II 8
MCS-51 Family Overview
Executing From External Program Memory
Example 87h
EPROM
Read P1 P0
Address 0421h 8 /EA
0
(87h) 5
LATCH
1 ALE Addr
P3 P2 /OE
/PSEN
MicroProcessor Part II 9
MCS-51 Family Overview
Executing From External Data Memory
Structure
P1 P0
RAM
8
0 LATCH
5
1 ALE Addr 216
( 0~64KB)
= 64KB
RD
P3 P2
WR
/CE
DECODING WR /OE
MicroProcessor Part II 10
MCS-51 Family Overview
Executing From External Data Memory
Timing - Read
CLK
1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4
ALE
PSEN
/RD
PORT2
PORT0
LATCH
Bus Cycle
MicroProcessor Part II 11
MCS-51 Family Overview
Executing From External Data Memory
Timing - Write
CLK
1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4
ALE
PSEN
/ WR
PORT2
PORT0
LATCH
Bus Cycle
MicroProcessor Part II 12
MCS-51 Family Overview
Instruction Decoder
BRANCH LOGIC
INT1
LOGIC
CONDITION
CARRY
UNIT ACC
TIMER
1. Store the OP Code ….
…
2. Decoding DECIMAL
3. Output Control Signal ADJUST
MicroProcessor Part II 13
MCS-51 Family Overview
Arithmetic Logic Unit
BRANCH LOGIC
INT1
LOGIC
CONDITION
CARRY
UNIT ACC
Input : 1 or 2 x 8bit data TIMER
Output : 8bit result data ….
1. +, - (carry) …
DECIMAL
2. Increment, Decrement ADJUST
3. Bit Complement
4. Rotate Left/Right
5. Nibble Exchange
6. *, /
MicroProcessor Part II 14
MCS-51 Family Overview
Accumulator
BRANCH LOGIC
INT1
LOGIC
CONDITION
CARRY
UNIT ACC.
TIMER
1. Store Input Data …
2. Store Result Data ....
DECIMAL
3. Transfer data to ADJUST
Memory and I/O
MicroProcessor Part II 15
MCS-51 Family Overview
CPU Timing (I)
OSC
(xtal1)
ALE
STATE S1 S2 S3 S4 S5 S6 S1 S2 S3 S4 S5 S6
MicroProcessor Part II 16
MCS-51 Family Overview
CPU Timing (II)
OSC
(xtal1)
ALE
STATE S1 S2 S3 S4 S5 S6 S1 S2 S4 S3 S5 S6
READ
NEXT
OPCODE
AGAIN
1-BYTE, 2-CYCLE Instruction (INC DPTR )
READ OPCODE
READ NEXT OPCODE ( DISCARD )
MicroProcessor Part II 17
MCS-51 Family Overview
CPU Timing (III)
OSC
(xtal1)
ALE
STATE S1 S2 S3 S4 S5 S6 S1 S2 S4 S3 S5 S6
MicroProcessor Part II 18
MCS-51 Family Overview
Memory Organization
Logical Separation of Program and Data Memory
PROGRAM MEMORY DATA MEMORY
(READ ONLY) (READ/WRITE ONLY)
FFFF FFFF
216 Ext
Ext
0FFF
FF
Int Int
4KB /EA=0 /EA=1
=4096B Ext Int
Int
0000 00
/ PSEN / RD / WR
MicroProcessor Part II 19
MCS-51 Family Overview
Program Memory
After reset, the CPU begins execution from location 0000h
The read Strobe to external ROM, /PSEN, is used for all external
program fetches. /PSEN is not activate for internal program fetches.
fetches
MicroProcessor Part II 20
MCS-51 Family Overview
Program Memory
002B
If an interrupt service routine is short
0023
enough ( as is often the case in control
001B applications), it can reside entirely
INTERRUPT within that the 8-byte interval.
LOCATIONS 0013
8 BYTE
000B
0003
RESET 0000
MicroProcessor Part II 21
MCS-51 Family Overview
Data Memory
Internal Data Memory space is shown divided into three blocks, which are generally
refereed to as the lower 128, the Upper 128, and SFR space
Internal Data Memory Address are always 1 byte wide ( 256Byte )
FF
Accessible by PORTS
direct Addressing STATUS BIT
UPPER 128 CONTROL BIT
Special Function Registers TIMER
REGISTERS
80 STACK POINT
7F ACCUMULATOR
Accessible by indirect (ETC..)
LOWER 128
Addressing only
00
Accessible by direct
and indirect addressing
MicroProcessor Part II 22
MCS-51 Family Overview
The Lower 128 Byte of internal RAM
3F ~ 7F STACK
20 ~ 2F BIT-ADDRESSABLE SPACE
11 18 ~ 1F
BANK
SELECT 10 10 ~ 17
4 BANKS OF REGISTER (R0~R7)
BIT IN 01 08 ~ 0F
PSW
00 00 ~ 07
MicroProcessor Part II 23
MCS-51 Family Overview
4 Banks Of Register
4 X 8 REGISTER BANK
R7
R6
R5
R4
R3
R2
R1
R0 4th REG. BANK
MicroProcessor Part II 24
MCS-51 Family Overview
Bit-Addressable Register
MicroProcessor Part II 25
MCS-51 Family Overview
Special Function Register (SFR) - (I)
MicroProcessor Part II 26
MCS-51 Family Overview
Special Function Register (SFR) - (II)
Internal Bit/Byte
Register Mnemonic
Address Access
Port 1 Latch P1 90 Bit
Serial Port Control SCON 98 Bit
Serial Data Port SBUF 99 Byte
Port 2 Latch P2 A0 Bit
Interrupt Enable IE A8 Bit
Port 3 Latch P3 B0 Bit
Interrupt Priority Control IP B8 Bit
Program Stats Word PSW D0 Bit
Accumulator Acc or A E0 Bit
B Regster B F0 Bit
MicroProcessor Part II 27
MCS-51 Family Overview
Special Function Register (SFR) - (III) - Software Control/Operation
MicroProcessor Part II 28
MCS-51 Family Overview
Special Function Register (SFR) - (III) - Internal Unit Control
Timer/Count
: TH1, TL1, TH0, TL0, TMOD, TCON
Serial Port
: SBUF, SCON, PCON
Interrupt control
: IE, IP
I/O Port
: P0, P1, P2, P3
MicroProcessor Part II 29
Chap2 . The Instruction of 8051 Family
Instruction Set
5 Groups - 51 Instructions
1. Data Transfers Instructions
2. Arithmetic Instructions
3. Logical Instructions
4. Boolean Instructions
5. Jump Instructions
MicroProcessor Part II 30
Chap2 . The Instruction of 8051 Family
The Concepts of OPCODE & OPERAND
Instruction Code
1 Byte Instr.
OP Code + Operand
MicroProcessor Part II 32
Chap2 . The Instruction of 8051 Family
Operation Code
: It define such operations as add, subtract, multiply, shift, and complem
ent.
Total number of operations obtained determines the set of machine o
perations.
perations
Opcode must consist of at least n bits for a given 2n (or less) distinct o
perations.
MicroProcessor Part II 33
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instructions
1.
1. The
The Immediate
Immediate Addressing
Addressing Mode
Mode
2.
2. The
The Direct
Direct Addressing
Addressing Mode
Mode
3.
3. The
The Register
Register Addressing
Addressing Mode
Mode
4.
4. The
The Register-Specific
Register-Specific Addressing
Addressing Mode
Mode
5.
5. The
The Register
Register Indirect
Indirect Addressing
Addressing Mode
Mode
6.
6. The
The Register
Register Indexed
Indexed Addressing
Addressing Mode
Mode
MicroProcessor Part II 34
Chap2 . The Instruction of 8051 Family
1.Data Transfer Instruction - The Immediate Addressing Mode
Ex )
MOV A , #33h MOV DPTR , #1234h
PROGRAM DPTR
ACC PROGRAM
MEMORY MEMORY DPH DPL
33h 12h 34h
74 OP CODE 90 OP CODE
33 IMMEDIATE DATA 12 IMMEDIATE DATA
34
MicroProcessor Part II 36
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instruction - The Immediate Addressing Mode
MicroProcessor Part II 37
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instruction - The Direct Addressing Mode
The Direct Addressing Mode
: The Direct addressing mode refers to specifying an internal data register or an SFR by its address.
MicroProcessor Part II 38
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instruction - The Direct Addressing Mode
Ex )
mov A , 33h mov 30h , R7
DATA DATA
MEMORY ACC R7 MEMORY
D1 DE
33h D1 DE 30h
DATA
DATA
Ex )
mov 30h , 35h mov 06h , 00h
DATA
85 30h D1 85 00h DE
30 06
35 35h D1 00
06h DE
DATA
MicroProcessor Part II 40
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instruction - The Direct Addressing Mode
Ex )
MicroProcessor Part II 41
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instruction - The Register Addressing Mode
MicroProcessor Part II 42
Chap2 . The Instruction of 8051 Family
Cf ) Program Status Word (PSW)
The PSW contains several status bit that reflect the current
state of the CPU.
CY AC F0 RS1 RS0 OV P
PSW7 PSW0
CARRY FLAG RECEIVES CARRY OUT PARITY OF ACCUMULATOR SET
FROM BIT 1 OF ALU OPERANDS BY HARDWARE TO 1 IF IT CONTAINS
AN ODD NUMBER OF 1S, OTHERWISE
IT IS RESET TO 0
PSW6
AUXILARY CARRY FLAG RECEIVES CARRY OUT PSW1
FROM BIT 1 OF ADDITION OPERANDS USER DEFINABLE FLAG
PSW5 PSW2
GENERAL PURPOSE STSTUS FLAG OVERFLOW FLAG SET
BY ARITHMETIC OPERATIONS
PSW4
REGISTER BANK SELECT BIT 1 PSW3
REGISTER BANK SELECT BIT 0
MicroProcessor Part II 43
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instruction - The Register-Specific Addressing Mode
MicroProcessor Part II 44
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instruction - The Register-Specific Addressing Mode
PROGRAM
MEMORY
MicroProcessor Part II 45
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instruction - The Register-Specific Addressing Mode
PROGRAM
MEMORY
MicroProcessor Part II 46
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instruction - The Register Indirect Addressing Mode
MicroProcessor Part II 47
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instruction - The Register Indirect Addressing Mode
Acc
DATA DATA
MEMORY 35 MEMORY
40h 35 50h AD
MicroProcessor Part II 48
Chap2 . The Instruction of 8051 Family
1.Data Transfer Instruction - The Register Indirect Addressing Mode
DATA
MEMORY
40h 55
R1 55
MicroProcessor Part II 49
Chap2 . The Instruction of 8051 Family
Addressing Mode - The Source & Destination of MOV Instruction
INTERNAL
DATA 7Fh FFh mov 77h, DPL
MEMORY SFR
mov b, a
MicroProcessor Part II 50
Chap2 . The Instruction of 8051 Family
Addressing Mode - The Source & Destination of MOV Instruction
mov 10h, 77h mov @R1, #33h
mov 33h, R7
Direct mov 3Fh, #33h
Addressing
Register Indirect
R0 ~ R1 Addressing
Immediate
Acc Data
mov a, #33h
MicroProcessor Part II 51
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instruction - The Register Indexed Addressing Mode
mov a , @a + DPTR
mov a , @a + PC
MicroProcessor Part II 52
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instruction - The Register Indexed Addressing Mode
MicroProcessor Part II 53
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instruction - The Register Indexed Addressing Mode
Org 2000h
PROGRAM
MEMORY mov a , #10h
movc a, @a + PC
2000h 74
mov a , #10h Acc
2001h 10 10h
2002h 83 movc a , @a+PC
+
2003h Current PC
PC
2003h 55h
2013h 55
MicroProcessor Part II 54
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instruction - The Stack Oriented Data Transfer
push acc ; Note that the operand acc is the symbol define to be 0E0h.
push a ; ( X ) : it uses the register-specific addressing mode.
MicroProcessor Part II 55
Chap2 . The Instruction of 8051 Family
1. Data Transfer Instruction - The Bit Oriented Data Transfer
Exchange Instruction
: Exchange Instructions perform powerful two-way data transfers without
the need for a temporary storage byte.
Two Exchange operations :
1. Byte-wise XCH
2. Nibble-wise XCHD (exchange digit)
Byte Nibble
MicroProcessor Part II 57
Chap2 . The Instruction of 8051 Family
2. Exchange Instruction
a R5 a @R1
Before 15 78 Before 12 34
After 78 15 After 34 12
XCH a , 30h
XCHD a , @R0
a (30h) a @R1
Before A5 37 Before 56 78
After 37 A5 After 58 76
MicroProcessor Part II 58
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Arithmetic Instructions
INC/DEC Instruction
: Register-specific, Register, Direct, Register Indirect Addressing
: Loop Counters, Pointers
Mnemonic :
INC Source Operand : Source Data = Source Data + 1
DEC Source Operand : Source Data = Source Data - 1
INC a
Acc CY AC OV P
Before FF -- -- -- X
After 00 -- -- -- 0
MicroProcessor Part II 59
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Arithmetic Instructions
DEC a
Acc CY AC OV P
Before 00 -- -- -- X
After FF -- -- -- 1
MicroProcessor Part II 60
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Arithmetic Instructions
ADD/SUB Instructions
Multi-Byte Adding
Acc, R0~R7
@R0, XXh
#XXh
MicroProcessor Part II 61
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Arithmetic Instructions
Ex ) ADD a, #32h
Acc CY AC OV P PSW
Before 76 -- -- -- --
After A8 -- -- 1 0
Sign Bit
0111 0110 (76h) (+)
Over Flow Flag + 0011 0010 (32h) (+)
(+) + (+ )
----------------------------
-128 ~ + 127
1010 1000 (A8h)
Result ( - ) ?
MicroProcessor Part II 62
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Arithmetic Instructions
Acc CY AC OV P
Before 86 -- -- -- --
After E8 -- -- 0 0
Sign Bit
1000 0110 (86h) (-)
(-) + (+) = (-) + 0110 0010 (62h) (+)
O.K.
----------------------------
1110 1000 (E8h)
Result ( - )
MicroProcessor Part II 63
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Arithmetic Instructions
Acc CY AC OV P
Before 55 1 -- -- --
Sign Bit
After A3 0 0 1 0
MicroProcessor Part II 64
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Arithmetic Instructions
Ex ) ADDC a, R5 R5 = 58h
Acc CY AC OV P
Before E9 0 -- -- --
Sign Bit
After 41 1 1 0 0
Result (+ )
MicroProcessor Part II 65
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Arithmetic Instructions
MicroProcessor Part II 66
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Arithmetic Instructions
Multiplication Instructions
MicroProcessor Part II 67
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Arithmetic Instructions
Division Instructions
B Result(portion)
DIV AB Acc / B
Acc Remainder
MicroProcessor Part II 68
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Logical Instructions
ANL
ORL Acc
Direct Addressing , # Data
XRL
CPL
CLR Acc
SWAP
MicroProcessor Part II 69
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Logical Instructions
CLR
CLR AA CLR A CPL
CPL AA CPL A
(CLear Acc ) (ComPlement Acc)
Before 10110101 b (B5h) Before 10110101 b (5Bh)
After 00000000 b (00h) After 01001010 b (4Ah)
ANL
ANL Dest,
Dest,Src
Src ORL
ORL Dest,
Dest,Src
Src
MicroProcessor Part II 70
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Logical Instructions
XRL
XRL Dest,
Dest,Src
Src
MicroProcessor Part II 71
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Logical Instructions
RL
RL Acc
Acc RR
RR Acc
Acc
(Rotate Acc Left ) (Rotate Acc Right )
a = # 73h a = # 73h
MicroProcessor Part II 72
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Logical Instructions
RLC
RLC Acc
Acc RRC
RRC Acc
Acc
(Rotate Acc & Carry Left ) (Rotate Acc & Carry Right )
CY CY
CY Acc CY Acc
Before 1 00011001 Before 1 10011000
After 0 00110011 After 0 11001100
MicroProcessor Part II 73
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Logical Instructions
SWAP
SWAP Acc
Acc
(SWAP Acc)
Acc
Before 11000011
After 00111100
MicroProcessor Part II 74
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Boolean Instructions
MicroProcessor Part II 76
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction
Program Counter
1. Branch Instructions
2. Subroutine Calls
3. Interrupts
MicroProcessor Part II 77
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Unconditional Jump Instructions
MicroProcessor Part II 78
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Unconditional Jump Instructions
051Eh 80
051Fh 06
Current PC
0520h
??
0520h +
0526h 0526h
MicroProcessor Part II 79
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Unconditional Jump Instructions
Org 0300h
SJMP BOT
User
User::JMP
JMP
…
RANGE CAA : MOVE A, R1
-128 ~ 127 … Compiler
Compiler
((IfIfRange
Range(-128
(-128~~127
127))))
…
MicroProcessor Part II 80
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Unconditional Jump Instructions
AJMP 01D2h
083Fh 21
0840h 01D2 = 0000 0001 1101 0010
D2
0841h
?? 0841 = 0000 1000 0100 0001
Current PC
LJMP 0A3Eh
0056h 02 3BYTE
0057h 0A
PC : 0A3E
0058h
3E
0A3Eh
0A3Fh
MicroProcessor Part II 82
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Unconditional Jump Instructions
Org 0300h
LJMP BOT
User
User::JMP
JMP
…
RANGE CAA : MOVE A, R1
… Compiler
Compiler
~ xxx
((IfIfRange
Range::
…
over
over-128
-128~~127
127))
BOT : INC A
LJMP
LJMP
….
….
MicroProcessor Part II 83
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Unconditional Jump Instructions
JMP @A+DPTR
03A7 73 Acc DPTR
0C 0410
PC
041C
MicroProcessor Part II 84
Chap2 . The Instruction of 8051 Family
2. Data Processing Instruction - Conditional Jump Instructions
MicroProcessor Part II 86
Chap3. Timer Interrupt & Optimize
Timer Interrupt
0FFF
PROGRAM
LOCATIONS
Longer service routines can be jump
instruction
002B
RI+TI
0023
INTERRUPT
TF1
001B
TABLE IE1 If an interrupt service routine is short
0013
enough ( as is often the case in control
TF0 8 BYTE
applications), it can reside entirely
000B
IE0 within that the 8-byte interval.
0003
RESET 0000
MicroProcessor Part II 87
Chap3. Timer Interrupt & Optimize
TCON Register
(MSB) (LSB)
NAME Function
Timer x over flow Flag
Set by hardware on timer/counter overflow
TFx
Cleared by hardware
when processor vectors to interrupt routine
(MSB) (LSB)
NAME Function
Interrupt x Edge flag
IEx Set by hardware when external interrupt edge detected
Cleared when interrupt processed.
(MSB) (LSB)
TIMER1 TIMER2
GATE Gating Control
When Set Timer/Counter “x”is enabled
Only while “INTx”pin is high and “TRx” control pin is set
When Cleared Timer “x” is enabled
Whenever “TRx” control bit is set
C/T Timer or Counter Selector
Cleared for Timer operation (input from internal system clock).
Set for Counter operation (input from “Tx” input pin)
MicroProcessor Part II 90
Chap3. Timer Interrupt & Optimize
TMOD Register - Operating Mode Control (0 , 1, 2 )
(MSB) (LSB)
TIMER1 TIMER2
M1 M0 Function
(MSB) (LSB)
TIMER1 TIMER2
Timer Function
T1 PIN C / T 1 CONTROL
TR1
GATE
INT1 PIN
MicroProcessor Part II 93
Chap3. Timer Interrupt & Optimize
Timer Mode - Mode 1
T1 PIN C / T 1 CONTROL
TR1
GATE
INT1 PIN
MicroProcessor Part II 94
Chap3. Timer Interrupt & Optimize
Timer Mode - Mode 2
T1 PIN C / T 1 CONTROL
RELOAD
TR1
TH1
GATE (8BITS)
INT1 PIN
MicroProcessor Part II 95
Chap3. Timer Interrupt & Optimize
Timer Mode - Mode 3
TL0
TF0 INTERRUPT
(8BITS)
T0 PIN C / T 1 CONTROL
TR0
MicroProcessor Part II 96
Chap3. Timer Interrupt & Optimize
Vector Table (Single Board Case)
EXTERNAL PROGRAM
MEMORY (ROM) In Our Single - Board Case,
Actual interrupt service routine
0023 have to be exist in the data memory area
(RAM address range: 8000H ~ 9FFFH)
001B
LJMP 80F9H TF1
LJMP 80F3H
000B
TF0