MICRO-CONTROLLER MOTOROLA HCS12 Instruction Set Mechatronics Department Faculty of Engineering Ain...
-
Upload
brett-perry -
Category
Documents
-
view
218 -
download
4
Transcript of MICRO-CONTROLLER MOTOROLA HCS12 Instruction Set Mechatronics Department Faculty of Engineering Ain...
MICRO-CONTROLLER MOTOROLA HCS12Instruction Set
Mechatronics
Department
Faculty of EngineeringAin Shams Univeristy
Memory on Chip
A B
X
Y
SP
PC
N Z V C
Processor Memory Specia
l Regist
er
RAM
ROM
MemoryPort T
Port
T
DDRT
DD
RT
MC68HC12 “Stepper Motor Control”
Port T3|2|1|0 $242
MC68HC12 “Stepper Motor Control”
Size equ 4;
PTT equ $240; Address of port T
DDRT equ $242; Data direction register for port T
org $4000;
------------------------------------------------------------------
main movb #$FF, DDRT; Set port T for output
Run ldaa #size; initialize counter in A
ldx #steps; Point to the steps in memory
step movb 1, x+, PTT; step the motor
dbne A, step; Decrement A and check if it’s zero
bra run;
Step Counter
Port T is a part of memory having Address $ 240
Data direction register of Port T is a part of memory having Address $ 242
steps 1001
steps +1
1010
steps +2
1001
steps +3
0110
Move Data instructionMove Data instructionMove Data instructionMove Data instructionDecision Making
Flow Control
MC68HC12 “Stepper Motor Control”
steps 0101
steps +1
1001
steps +2
1010
steps +3
0110
A B
X
Y
SP
PC
N Z V C
!4ldaa#4ldx#steps
Steps
Port Tmovb 1, x+, PTT
Steps +1
0101
dbne A, step!3
$4003$4005$4008$400B$400F$4008
movb 1, x+, PTT
$400B
Steps +2
1001$400F
dbne A, step!2
$4008
movb 1, x+, PTT
$400B
Steps +3
1010
$400F
dbne A, step!1
$4008
movb 1, x+, PTT
Steps +4
0110
$400B
dbne A, step
$400F
!0brarun
$4003
ldx#stepsldaa#4!4
Steps
$4005$400B
HCS12 Instruction Set
Move data. Modify data. Decision making. Flow control.
Push and Pull instructions
$5005
….
$5006
….
$5007
….
$5008
….
$5009
….
$500A
….
$500B
….
$500C
….
A B
X
Y
SP
PC
N Z V C
$5005
PULA;
Stack Pointer
Sta
ck
$FF
Sta
ck
PSHA;
$5006
Bit manipulation instructions
$5005
….
$5006
….
$5007
….
$5008
….
$5009
….
$500A
….
$500B
….
$500C
….
BSET$5005,$6A;
$B0$B0
$6A
% 1 0 1 1 0 0 0 0% 0 1 1 0 1 0 1 0
% 1 1 1 1 1 0 1 0
$FA
Eng. Mohamed Mahmoud Hamdy
Eng. Mostafa Ahmed Arafa
Prepared by: