forked from erinjense/LED-slave-MC9S08QG8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
led_bar.sub
136 lines (115 loc) · 4.86 KB
/
led_bar.sub
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
;*******************************************************************************
; EE465: Microcontroller Applications
; Montana State University, Bozeman
; by Aaron Jense
;
; Compares iic_msg_rx for keypress of A,B,C,D
; If match found, display pattern by setting PTBD for each index in PATTERN_
; 1 sec delay between each index tracked by pcount and _VTPMOVF interrupt
;*******************************************************************************
#ListOff
#Uses qg8.inc
#Uses iic.sub
#ListOn
;*******************************************************************************
; Constants
;*******************************************************************************
TPMSC_TOF pin TPMSC,7
;*******************************************************************************
#RAM
;*******************************************************************************
pcount rmb 1
;*******************************************************************************
#ROM
;*******************************************************************************
PATTERN_A fcb %10101010
#size PATTERN_A
PATTERN_B fcb %01111111
fcb %10111111
fcb %11011111
fcb %11101111
fcb %11110111
fcb %11111011
fcb %11111101
fcb %11111110
#size PATTERN_B
PATTERN_C fcb %00011000
fcb %00100100
fcb %01000010
fcb %10000001
fcb %01000010
fcb %00100100
fcb %00011000
#size PATTERN_C
PATTERN_D fcb %00111100
fcb %00011110
fcb %00001111
fcb %00000111
fcb %00000011
fcb %00000001
fcb %00000011
fcb %00000111
fcb %00001111
fcb %00011110
fcb %00111100
#size PATTERN_D
;*******************************************************************************
FLASH_LED_ARRAY proc
clrhx ; inits
clr pcount
clr PTBD
lda iic_msg_rx ; compare
cbeqa #'A',LED_A
cbeqa #'B',LED_B
cbeqa #'C',LED_C
cbeqa #'D',LED_D
rts
;*******************************************************************************
LED_A proc
Loop@@ lda PATTERN_A
sta PTBD
lda pcount
cmpa #::PATTERN_A
bne Loop@@
clr iic_msg_rx
clr PTBD
rts
;*******************************************************************************
LED_B proc
Loop@@ ldx pcount
lda PATTERN_B,x
sta PTBD
lda pcount
cmpa #::PATTERN_B
bne Loop@@
clr iic_msg_rx
clr PTBD
rts
;*******************************************************************************
LED_C proc
Loop@@ ldx pcount
lda PATTERN_C,x
sta PTBD
lda pcount
cmpa #::PATTERN_C
bne Loop@@
clr iic_msg_rx
clr PTBD
rts
;*******************************************************************************
LED_D proc
Loop@@ ldx pcount
lda PATTERN_D,x
sta PTBD
lda pcount
cmpa #::PATTERN_D
bne Loop@@
clr iic_msg_rx
clr PTBD
rts
;*******************************************************************************
_VTPMOVF proc
bclr TPMSC_TOF ; must clear TOF flag
inc pcount
rti
;*******************************************************************************