Chapter 1: 68HC11 MICROCONTROLLER
1.1 Introduction
§ 68HC11, an 8-bit microcontroller manufactured by Motorola.
§ 68HC11 IC chip consists of the following blocks:
- CPU ( central processing unit )
- Memory ( RAM, EPROM, EEPROM )
- I/O units ( Parallel Ports, Timer, SCI and ADC )
• Applications of the 68HC11:
controlling washing machine, hard disk drive , etc.
1
1.1 Basic 68HC11 Block Diagram
Address Bus (16-Bit)
Control Control
CPU Memory I/O
Bus Bus
Data Bus (8-Bit)
2
1.2 Programming Model of the 68HC11
7 A 0 7 B 0 8-bit Accumulator A & B
15 D 0 16-bit Double Accumulator D
15 X 0 Index Register X
15 Y 0 Index Register Y
15 PC 0 Program Counter PC
15 SP 0 Stack Pointer SP
S = Stop Disable
S X H I N Z V C Condition Code Register CCR
X = X Interrupt Mask
H = Half Carry C = Carry
I = I Interrupt mask V = Overflow
N = Negative Z = Zero
3
1.2.1 Accumulator A and B
D7 D6 D5 D4 D3 D2 D1 D0
ACCA or
0 1 1 0 0 1 1 1
ACCB
§ ACCA or ACCB is an 8-bit general-purpose register
§ Usage of ACCA or ACCB:
- Stores temporary data from memory or I/O devices.
- Stores result of all arithmetic and logic operations.
4
1.2.1 Accumulator A and B
Ø Example:
1. LDAA $8000 ; loads contents of memory
Acc.A ; location $8000 into ACCA
2. ADDA #$25 ; ACCA = ACCA + $25
3. STAA $9000 ; store result of ACCA into
; memory location $9000
5
1.2.2 Accumulator D
BITS 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 ACCD
ACCA ACCB
§ ACCD represents Accumulator D
§ ACCD = (ACCA + ACCB) to form a 16-bit register.
§ ACCA represents most significant byte (MSByte)
§ ACCB represents least significant byte (LSByte)
6
1.2.3 Index Register X and Y
BITS 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0
INDEX-X or INDEX-Y register
§ Index register X and Y are two 16-bit registers.
§ Use in Index Addressing Mode.
Ø Examples:
LDX #$1000 ;loads $1000 into IX
LDAA $10,X ;content of memory ($10+IX)
;load to ACCA.
7
1.2.4 Stack Pointer
BITS 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SP
0 0 0 0 1 1 0 0 0 0 1 1 0 1 1 0
register
§ Stack occupied a small section in RAM memory.
§ Stack Pointer (SP) register:
- a 16-bit register.
- contains address of the stack.
§ Application of stack :
- used in subroutine and interrupts operations
- storing the content of all the CPU registers.
8
1.2.5 Program Counter (PC)
BITS 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 0 0 0 0 1 1 0 1 1 0 PC
§ Program Counter (PC) is a 16-bit register .
§ PC contains the address of next instruction to be executed.
§ Example:
If PC = $0100, then ,
CPU starts executing from memory location $0100
onwards.
9
1.2.6 Condition Code Register ( CCR )
D7 D6 D5 D4 D3 D2 D1 D0
S X H I N Z V C CCR
§ CCR is an 8-bit register.
§ Bits 7 to 0 labeled as S X H I N Z V C respectively.
§ H N Z V C bits indicate:
- the status of last arithmetic or logic operation.
§ S X I bits indicate:
- the masking bits.
10
Condition Code Register
bit 7 6 5 4 3 2 1 bit 0
S X H I N Z V C CCR
Stop Disable Carry
X Interrupt Mask Overflow
Half Carry Zero
I Interrupt Mask Negative
11
§ N (Negative) bit
N = “1” - result of last arithmetic or logical operation
is negative.
- accumulator contents (MSB = “1”)
N =“0” - whenever the result is positive.
- accumulator contents (MSB = “0”)
Ø Example, if following instructions are executed:
(1) LDAA #$7F ; N = “0” , MSB = “0”
(2) LDAB #$80 ; N = “1” , MSB = “1”
12
§ Z (Zero) bit
Z = “1” - result of last operation produces zero.
- accumulator content = $00
Z = “0” - result of last operation greater than zero.
- accumulator content == $00
Ø Example, if the following instructions are executed
(assuming ACCA and ACCB = $00 in the beginning):
(1) ADDA #$00 ; Z = “1” ,ACCA= $00
(2) ADDB #$06 ; Z = “0” ,ACCB > $00
13
§ C (Carry) bit
C =“1” addition or subtraction produces
a carry or a borrow.
C =“0” after addition or subtraction
no carry or no borrow.
*Note: C-bit also used in shift and rotate instructions.
ØExample, if the following instructions are executed:
LDAA #$80
ADDA #$90 ; C=“1”
WAI ; bit-7 carries “1” to C-bit
14
§ V(Overflow) bit
V =“1” result is wrong, after
an addition or subtraction using
2’s complement signed number.
V =“0” result is correct, after
an addition or subtraction using
2’s complement signed number.
15
§ H(Half-carry) bit
H =“1” an 8-bit addition, produces
a carry from bit-3 to bit-4.
H =“0” an 8-bit addition, produces
no carry from bit-3 to bit-4.
ØExample, following instructions are executed:
“1”
LDAA #% 0011 1000
ADDA #% 0011 1010 ; H=“1”
WAI ;(after adding)
16
Review :
1 ) Why is 68HC11 known as an 8 bits microcontroller?
_________________________________________
2) What are the main elements inside the 68HC11?
__________________________________________
3)What is a programming model?
___________________________________________
17