-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathButtonTest.asm
More file actions
69 lines (56 loc) · 1.04 KB
/
ButtonTest.asm
File metadata and controls
69 lines (56 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
; Starting code with basic constants and simple subroutine
; random comment
ORG 0
Start:
IN BTN
JPOS Testpos
JZERO Testzero
Testpos:
LOADI 1
OUT Hex0
JUMP Start
Testzero:
LOADI 5
OUT Hex0
JUMP Start
ReadVelocity:
CALL Delay
IN Quad
SUB OldPos
SHIFT 5
OUT Hex0
STORE CurrVel
IN Quad
STORE OldPos
RETURN
Delay:
OUT Timer ; writing something to timer resets it to 0
WaitingLoop:
IN Timer ; time counts up to 10 in 1 sec or at 10 Hz
ADDI -1 ; waiting 1/32 of a second
JNEG WaitingLoop
RETURN
; IO address constants
Switches: EQU &H000
Hex0: EQU &H004
Hex1: EQU &H005
PWM: EQU &H021
Direct: EQU &H022
BTN: EQU &H023
Quad: EQU &H0F1
Timer: EQU &H002
; constants
Zero: DW 0
NegOne: DW -1
VelControlOn: DW 1
PosControlOn: DW 0
VelControl: DW &B01111
PosControlSpeed: DW &B11001
PosControl: DW 540
Countprev: DW 0
OldPos: DW 0
DesiredVel: DW 270 ; 360 = 1 rev in 1.5 seconds
CurrVel: DW 0
PWMSpeed: DW 20
DesiredPos: DW 5400
Velocity: DW 0