OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src/] [tA_compare.s43] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 olivier.gi
/*===========================================================================*/
2
/* Copyright (C) 2001 Authors                                                */
3
/*                                                                           */
4
/* This source file may be used and distributed without restriction provided */
5
/* that this copyright statement is not removed from the file and that any   */
6
/* derivative work contains the original copyright notice and the associated */
7
/* disclaimer.                                                               */
8
/*                                                                           */
9
/* This source file is free software; you can redistribute it and/or modify  */
10
/* it under the terms of the GNU Lesser General Public License as published  */
11
/* by the Free Software Foundation; either version 2.1 of the License, or    */
12
/* (at your option) any later version.                                       */
13
/*                                                                           */
14
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
15
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     */
16
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public       */
17
/* License for more details.                                                 */
18
/*                                                                           */
19
/* You should have received a copy of the GNU Lesser General Public License  */
20
/* along with this source; if not, write to the Free Software Foundation,    */
21
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA        */
22
/*                                                                           */
23
/*===========================================================================*/
24
/*                                  TIMER A                                  */
25
/*---------------------------------------------------------------------------*/
26
/* Test the timer A:                                                         */
27
/*                        - Check the timer compare features.                */
28
/*===========================================================================*/
29
 
30
.global main
31
 
32
.set   TACTL,   0x0160
33
.set   TAR,     0x0170
34
.set   TACCTL0, 0x0162
35
.set   TACCR0,  0x0172
36
.set   TACCTL1, 0x0164
37
.set   TACCR1,  0x0174
38
.set   TACCTL2, 0x0166
39
.set   TACCR2,  0x0176
40
.set   TAIV,    0x012E
41
 
42
 
43
WAIT_FUNC:
44
        dec r14
45
        jnz WAIT_FUNC
46
        ret
47
 
48
main:
49
        mov  #0x0250, r1        ; # Initialize stack pointer
50
        mov  #0x0000, &0x0200
51
 
52
 
53
       /* --------------   TIMER A TEST:  UP MODE   ----------------- */
54
 
55
        mov  #0x0200, &TACTL
56
        mov  #0x0000, &TACCTL0
57
        mov  #0x0000, &TACCTL1
58
        mov  #0x0000, &TACCTL2
59
        eint
60
 
61
                                ; # --------- COMPARATOR 0 ----------
62
        mov  #0x0204, &TACTL
63
        mov  #0x0015, &TACCR0   ; # Period = (0x15+1)*2
64
        mov  #0x0090, &TACCTL0  ; # Compare mode, output toggle mode, IRQ enabled
65
        mov  #0x0000, &TACCR1   ; #
66
        mov  #0x0000, &TACCTL1  ; # Disabled
67
        mov  #0x0000, &TACCR2   ; #
68
        mov  #0x0000, &TACCTL2  ; # Disabled
69
        mov  #0x0256, &TACTL    ; # Up-mode & clk/2, IRQ enabled
70
        mov  #0x0001, &0x0200
71
        mov  #0x0010, r14
72
        call #WAIT_FUNC
73
 
74
                                ; # --------- COMPARATOR 1 ----------
75
        mov  #0x0204, &TACTL
76
        mov  #0x0015, &TACCR0   ; # Period = (0x15+1)*2
77
        mov  #0x0000, &TACCTL0  ; #
78
        mov  #0x0090, &TACCTL0  ; # Compare mode, output toggle mode, IRQ enabled
79
        mov  #0x0005, &TACCR1   ; #
80
        mov  #0x0090, &TACCTL1  ; # Compare mode, output toggle mode, IRQ enabled
81
        mov  #0x0000, &TACCR2   ; #
82
        mov  #0x0000, &TACCTL2  ; # Disabled
83
        mov  #0x0254, &TACTL    ; # Up-mode & clk/2
84
        mov  #0x0002, &0x0200
85
        mov  #0x0008, r14
86
        call #WAIT_FUNC
87
 
88
                                ; # --------- COMPARATOR 2 ----------
89
        mov  #0x0204, &TACTL
90
        mov  #0x0015, &TACCR0   ; # Period = (0x15+1)*2
91
        mov  #0x0000, &TACCTL0  ; #
92
        mov  #0x0090, &TACCTL0  ; # Compare mode, output toggle mode, IRQ enabled
93
        mov  #0x0000, &TACCR1   ; #
94
        mov  #0x0000, &TACCTL1  ; # Disabled
95
        mov  #0x000C, &TACCR2   ; #
96
        mov  #0x0090, &TACCTL2  ; # Compare mode, output toggle mode, IRQ enabled
97
        mov  #0x0254, &TACTL    ; # Up-mode & clk/2
98
        mov  #0x0003, &0x0200
99
        mov  #0x0008, r14
100
        call #WAIT_FUNC
101
 
102
 
103
        dint
104
        mov  #0x0000, &0x0200
105
        mov  #0x1000, r15
106
 
107
 
108
       /* --------------   TIMER A TEST:  CONTINUOUS MODES   ----------------- */
109
 
110
        mov  #0x0200, &TACTL
111
        mov  #0x0000, &TACCTL0
112
        mov  #0x0000, &TACCTL1
113
        mov  #0x0000, &TACCTL2
114
        eint
115
 
116
                                ; # --------- COMPARATOR 0, 1 and 2 - TEST 1 ----------
117
        mov  #0x0204, &TACTL
118
        mov  #0x0030, &TACCR0
119
        mov  #0x0090, &TACCTL0  ; # Compare mode, output toggle mode, IRQ enabled
120
        mov  #0x0060, &TACCR1
121
        mov  #0x0090, &TACCTL1  ; # Compare mode, output toggle mode, IRQ enabled
122
        mov  #0x0090, &TACCR2
123
        mov  #0x0090, &TACCTL2  ; # Compare mode, output toggle mode, IRQ enabled
124
        mov  #0x0266, &TACTL    ; # Continuous-mode & clk/2, IRQ enabled
125
        mov  #0xfff0, &TAR
126
        mov  #0x0001, &0x0200
127
        mov  #0x0080, r14
128
        call #WAIT_FUNC
129
 
130
                                ; # --------- COMPARATOR 0, 1 and 2 - TEST 2 ----------
131
        mov  #0x0204, &TACTL
132
        mov  #0x0030, &TACCR0
133
        mov  #0x0090, &TACCTL0  ; # Compare mode, output toggle mode, IRQ enabled
134
        mov  #0x0060, &TACCR1
135
        mov  #0x0090, &TACCTL1  ; # Compare mode, output toggle mode, IRQ enabled
136
        mov  #0x0090, &TACCR2
137
        mov  #0x0090, &TACCTL2  ; # Compare mode, output toggle mode, IRQ enabled
138
        mov  #0x0266, &TACTL    ; # Continuous-mode & clk/2, IRQ enabled
139
        mov  #0xfff0, &TAR
140
        mov  #0x0002, &0x0200
141
        mov  #0x0080, r14
142
        call #WAIT_FUNC
143
 
144
 
145
        dint
146
        mov  #0x0000, &0x0200
147
        mov  #0x2000, r15
148
 
149
 
150
       /* --------------   TIMER A TEST:  UP-DOWN MODE   ----------------- */
151
 
152
        mov  #0x0200, &TACTL
153
        mov  #0x0000, &TACCTL0
154
        mov  #0x0000, &TACCTL1
155
        mov  #0x0000, &TACCTL2
156
        eint
157
 
158
                                ; # --------- COMPARATOR 0, 1 and 2  ----------
159
        mov  #0x0204, &TACTL
160
        mov  #0x0090, &TACCR0
161
        mov  #0x0090, &TACCTL0  ; # Compare mode, output toggle mode, IRQ enabled
162
        mov  #0x0060, &TACCR1
163
        mov  #0x0090, &TACCTL1  ; # Compare mode, output toggle mode, IRQ enabled
164
        mov  #0x0030, &TACCR2
165
        mov  #0x0090, &TACCTL2  ; # Compare mode, output toggle mode, IRQ enabled
166
        mov  #0x0001, &0x0200
167
        mov  #0x0277, &TACTL    ; # Up-down mode & clk/2, IRQ enabled
168
        mov  #0x00E0, r14
169
        call #WAIT_FUNC
170
 
171
        mov  #0x0000, &TACCTL0
172
        mov  #0x0000, &TACCTL1
173
        mov  #0x0000, &TACCTL2
174
        mov  #0x0204, &TACTL
175
 
176
                                ; # --------- COMPARATOR 0, 1 and 2  ----------
177
        mov  #0x0204, &TACTL
178
        mov  #0x0090, &TACCR0
179
        mov  #0x0090, &TACCTL0  ; # Compare mode, output toggle mode, IRQ enabled
180
        mov  #0x0060, &TACCR1
181
        mov  #0x0090, &TACCTL1  ; # Compare mode, output toggle mode, IRQ enabled
182
        mov  #0x0030, &TACCR2
183
        mov  #0x0090, &TACCTL2  ; # Compare mode, output toggle mode, IRQ enabled
184
        mov  #0x0002, &0x0200
185
        mov  #0x0277, &TACTL    ; # Up-down mode & clk/2, IRQ enabled
186
        mov  #0x00E0, r14
187
        call #WAIT_FUNC
188
 
189
 
190
        dint
191
        mov  #0x0000, &0x0200
192
        mov  #0x3000, r15
193
 
194
        /* --------------   TIMER A TEST:  CCI INPUT LATCHING (SCCI)  ----------------- */
195
 
196
        mov  #0x0200, &TACTL
197
        mov  #0x0000, &TACCTL0
198
        mov  #0x0000, &TACCTL1
199
        mov  #0x0000, &TACCTL2
200
        eint
201
 
202
                                ; # --------- UP-MODE - COMPARATOR 0 ----------
203
        mov  #0x0204, &TACTL
204
        mov  #0x0020, &TACCR0
205
        mov  #0x3080, &TACCTL0  ; # Compare mode, output toggle mode, select VCC input
206
        mov  #0x0000, &TACCR1
207
        mov  #0x0000, &TACCTL1  ; # Disabled
208
        mov  #0x0000, &TACCR2
209
        mov  #0x0000, &TACCTL2  ; # Disabled
210
        mov  #0x0001, &0x0200
211
        mov  #0x0254, &TACTL    ; # Up-mode & clk/2
212
 
213
comp0_check_0:                  ; # Wait until SCCI is set to 1
214
        mov       r5, &0x0202
215
        mov &TACCTL0, r5
216
        mov       r5, r4
217
        and  #0x0001, r4
218
        jz  comp0_check_0
219
        mov &TACCTL0, &0x0204
220
 
221
        mov  #0x2080, &TACCTL0  ; # Wait until SCCI is set back to 0
222
comp0_check_1:
223
        mov       r5, &0x0206
224
        mov &TACCTL0, r5
225
        mov       r5, r4
226
        and  #0x0001, r4
227
        jz  comp0_check_1
228
        mov &TACCTL0, &0x0208
229
 
230
 
231
                                ; # --------- UP-MODE - COMPARATOR 1 ----------
232
        mov  #0x0204, &TACTL
233
        mov  #0x0040, &TACCR0
234
        mov  #0x0000, &TACCTL0  ; # Disabled
235
        mov  #0x0020, &TACCR1
236
        mov  #0x3080, &TACCTL1  ; # Compare mode, output toggle mode, select VCC input
237
        mov  #0x0000, &TACCR2
238
        mov  #0x0000, &TACCTL2  ; # Disabled
239
        mov  #0x0002, &0x0200
240
        mov  #0x0254, &TACTL    ; # Up-mode & clk/2
241
 
242
comp1_check_0:                  ; # Wait until SCCI is set to 1
243
        mov       r5, &0x0212
244
        mov &TACCTL1, r5
245
        mov       r5, r4
246
        and  #0x0001, r4
247
        jz  comp1_check_0
248
        mov &TACCTL1, &0x0214
249
 
250
        mov  #0x2080, &TACCTL1  ; # Wait until SCCI is set back to 0
251
comp1_check_1:
252
        mov       r5, &0x0216
253
        mov &TACCTL1, r5
254
        mov       r5, r4
255
        and  #0x0001, r4
256
        jz  comp1_check_1
257
        mov &TACCTL1, &0x0218
258
 
259
 
260
                                ; # --------- UP-MODE - COMPARATOR 2 ----------
261
        mov  #0x0204, &TACTL
262
        mov  #0x0040, &TACCR0
263
        mov  #0x0000, &TACCTL0  ; # Disabled
264
        mov  #0x0000, &TACCR1
265
        mov  #0x0000, &TACCTL1  ; # Disabled
266
        mov  #0x0020, &TACCR2
267
        mov  #0x3080, &TACCTL2  ; # Compare mode, output toggle mode, select VCC input
268
        mov  #0x0003, &0x0200
269
        mov  #0x0254, &TACTL    ; # Up-mode & clk/2
270
 
271
comp2_check_0:                  ; # Wait until SCCI is set to 1
272
        mov       r5, &0x0222
273
        mov &TACCTL2, r5
274
        mov       r5, r4
275
        and  #0x0001, r4
276
        jz  comp2_check_0
277
        mov &TACCTL2, &0x0224
278
 
279
        mov  #0x2080, &TACCTL2  ; # Wait until SCCI is set back to 0
280
comp2_check_1:
281
        mov       r5, &0x0226
282
        mov &TACCTL2, r5
283
        mov       r5, r4
284
        and  #0x0001, r4
285
        jz  comp2_check_1
286
        mov &TACCTL2, &0x0228
287
 
288
 
289
        dint
290
        mov  #0x0000, &0x0200
291
        mov  #0x4000, r15
292
 
293
 
294
        /* ----------------------         END OF TEST        --------------- */
295
end_of_test:
296
        nop
297
        br #0xffff
298
 
299
 
300
        /* ----------------------      INTERRUPT ROUTINES    --------------- */
301
 
302
TIMERA_CCR0_VECTOR:
303
        mov     &TAR, &0x0202
304
        reti
305
 
306
 
307
TIMERA_TAIV_VECTOR:
308
        mov     &TAR, &0x0204
309
        mov    &TAIV, &0x0206
310
        reti
311
 
312
 
313
        /* ----------------------         INTERRUPT VECTORS  --------------- */
314
 
315
.section .vectors, "a"
316
.word end_of_test        ; Interrupt  0 (lowest priority)    
317
.word end_of_test        ; Interrupt  1                      
318
.word end_of_test        ; Interrupt  2                      
319
.word end_of_test        ; Interrupt  3                      
320
.word end_of_test        ; Interrupt  4                      
321
.word end_of_test        ; Interrupt  5                      
322
.word end_of_test        ; Interrupt  6                      
323
.word end_of_test        ; Interrupt  7                      
324
.word TIMERA_TAIV_VECTOR ; Interrupt  8                      
325
.word TIMERA_CCR0_VECTOR ; Interrupt  9                      
326
.word end_of_test        ; Interrupt 10                      Watchdog timer
327
.word end_of_test        ; Interrupt 11                      
328
.word end_of_test        ; Interrupt 12                      
329
.word end_of_test        ; Interrupt 13                      
330
.word end_of_test        ; Interrupt 14                      NMI
331
.word main               ; Interrupt 15 (highest priority)   RESET

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.