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 19

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 18 olivier.gi
/*                                                                           */
29
/* Author(s):                                                                */
30
/*             - Olivier Girard,    olgirard@gmail.com                       */
31
/*                                                                           */
32
/*---------------------------------------------------------------------------*/
33 19 olivier.gi
/* $Rev: 19 $                                                                */
34
/* $LastChangedBy: olivier.girard $                                          */
35
/* $LastChangedDate: 2009-08-04 23:47:15 +0200 (Tue, 04 Aug 2009) $          */
36 2 olivier.gi
/*===========================================================================*/
37
 
38
.global main
39
 
40
.set   TACTL,   0x0160
41
.set   TAR,     0x0170
42
.set   TACCTL0, 0x0162
43
.set   TACCR0,  0x0172
44
.set   TACCTL1, 0x0164
45
.set   TACCR1,  0x0174
46
.set   TACCTL2, 0x0166
47
.set   TACCR2,  0x0176
48
.set   TAIV,    0x012E
49
 
50
 
51
WAIT_FUNC:
52
        dec r14
53
        jnz WAIT_FUNC
54
        ret
55
 
56
main:
57
        mov  #0x0250, r1        ; # Initialize stack pointer
58
        mov  #0x0000, &0x0200
59
 
60
 
61
       /* --------------   TIMER A TEST:  UP MODE   ----------------- */
62
 
63
        mov  #0x0200, &TACTL
64
        mov  #0x0000, &TACCTL0
65
        mov  #0x0000, &TACCTL1
66
        mov  #0x0000, &TACCTL2
67
        eint
68
 
69
                                ; # --------- COMPARATOR 0 ----------
70
        mov  #0x0204, &TACTL
71
        mov  #0x0015, &TACCR0   ; # Period = (0x15+1)*2
72
        mov  #0x0090, &TACCTL0  ; # Compare mode, output toggle mode, IRQ enabled
73
        mov  #0x0000, &TACCR1   ; #
74
        mov  #0x0000, &TACCTL1  ; # Disabled
75
        mov  #0x0000, &TACCR2   ; #
76
        mov  #0x0000, &TACCTL2  ; # Disabled
77
        mov  #0x0256, &TACTL    ; # Up-mode & clk/2, IRQ enabled
78
        mov  #0x0001, &0x0200
79
        mov  #0x0010, r14
80
        call #WAIT_FUNC
81
 
82
                                ; # --------- COMPARATOR 1 ----------
83
        mov  #0x0204, &TACTL
84
        mov  #0x0015, &TACCR0   ; # Period = (0x15+1)*2
85
        mov  #0x0000, &TACCTL0  ; #
86
        mov  #0x0090, &TACCTL0  ; # Compare mode, output toggle mode, IRQ enabled
87
        mov  #0x0005, &TACCR1   ; #
88
        mov  #0x0090, &TACCTL1  ; # Compare mode, output toggle mode, IRQ enabled
89
        mov  #0x0000, &TACCR2   ; #
90
        mov  #0x0000, &TACCTL2  ; # Disabled
91
        mov  #0x0254, &TACTL    ; # Up-mode & clk/2
92
        mov  #0x0002, &0x0200
93
        mov  #0x0008, r14
94
        call #WAIT_FUNC
95
 
96
                                ; # --------- COMPARATOR 2 ----------
97
        mov  #0x0204, &TACTL
98
        mov  #0x0015, &TACCR0   ; # Period = (0x15+1)*2
99
        mov  #0x0000, &TACCTL0  ; #
100
        mov  #0x0090, &TACCTL0  ; # Compare mode, output toggle mode, IRQ enabled
101
        mov  #0x0000, &TACCR1   ; #
102
        mov  #0x0000, &TACCTL1  ; # Disabled
103
        mov  #0x000C, &TACCR2   ; #
104
        mov  #0x0090, &TACCTL2  ; # Compare mode, output toggle mode, IRQ enabled
105
        mov  #0x0254, &TACTL    ; # Up-mode & clk/2
106
        mov  #0x0003, &0x0200
107
        mov  #0x0008, r14
108
        call #WAIT_FUNC
109
 
110
 
111
        dint
112
        mov  #0x0000, &0x0200
113
        mov  #0x1000, r15
114
 
115
 
116
       /* --------------   TIMER A TEST:  CONTINUOUS MODES   ----------------- */
117
 
118
        mov  #0x0200, &TACTL
119
        mov  #0x0000, &TACCTL0
120
        mov  #0x0000, &TACCTL1
121
        mov  #0x0000, &TACCTL2
122
        eint
123
 
124
                                ; # --------- COMPARATOR 0, 1 and 2 - TEST 1 ----------
125
        mov  #0x0204, &TACTL
126
        mov  #0x0030, &TACCR0
127
        mov  #0x0090, &TACCTL0  ; # Compare mode, output toggle mode, IRQ enabled
128
        mov  #0x0060, &TACCR1
129
        mov  #0x0090, &TACCTL1  ; # Compare mode, output toggle mode, IRQ enabled
130
        mov  #0x0090, &TACCR2
131
        mov  #0x0090, &TACCTL2  ; # Compare mode, output toggle mode, IRQ enabled
132
        mov  #0x0266, &TACTL    ; # Continuous-mode & clk/2, IRQ enabled
133
        mov  #0xfff0, &TAR
134
        mov  #0x0001, &0x0200
135
        mov  #0x0080, r14
136
        call #WAIT_FUNC
137
 
138
                                ; # --------- COMPARATOR 0, 1 and 2 - TEST 2 ----------
139
        mov  #0x0204, &TACTL
140
        mov  #0x0030, &TACCR0
141
        mov  #0x0090, &TACCTL0  ; # Compare mode, output toggle mode, IRQ enabled
142
        mov  #0x0060, &TACCR1
143
        mov  #0x0090, &TACCTL1  ; # Compare mode, output toggle mode, IRQ enabled
144
        mov  #0x0090, &TACCR2
145
        mov  #0x0090, &TACCTL2  ; # Compare mode, output toggle mode, IRQ enabled
146
        mov  #0x0266, &TACTL    ; # Continuous-mode & clk/2, IRQ enabled
147
        mov  #0xfff0, &TAR
148
        mov  #0x0002, &0x0200
149
        mov  #0x0080, r14
150
        call #WAIT_FUNC
151
 
152
 
153
        dint
154
        mov  #0x0000, &0x0200
155
        mov  #0x2000, r15
156
 
157
 
158
       /* --------------   TIMER A TEST:  UP-DOWN MODE   ----------------- */
159
 
160
        mov  #0x0200, &TACTL
161
        mov  #0x0000, &TACCTL0
162
        mov  #0x0000, &TACCTL1
163
        mov  #0x0000, &TACCTL2
164
        eint
165
 
166
                                ; # --------- COMPARATOR 0, 1 and 2  ----------
167
        mov  #0x0204, &TACTL
168
        mov  #0x0090, &TACCR0
169
        mov  #0x0090, &TACCTL0  ; # Compare mode, output toggle mode, IRQ enabled
170
        mov  #0x0060, &TACCR1
171
        mov  #0x0090, &TACCTL1  ; # Compare mode, output toggle mode, IRQ enabled
172
        mov  #0x0030, &TACCR2
173
        mov  #0x0090, &TACCTL2  ; # Compare mode, output toggle mode, IRQ enabled
174
        mov  #0x0001, &0x0200
175
        mov  #0x0277, &TACTL    ; # Up-down mode & clk/2, IRQ enabled
176
        mov  #0x00E0, r14
177
        call #WAIT_FUNC
178
 
179
        mov  #0x0000, &TACCTL0
180
        mov  #0x0000, &TACCTL1
181
        mov  #0x0000, &TACCTL2
182
        mov  #0x0204, &TACTL
183
 
184
                                ; # --------- COMPARATOR 0, 1 and 2  ----------
185
        mov  #0x0204, &TACTL
186
        mov  #0x0090, &TACCR0
187
        mov  #0x0090, &TACCTL0  ; # Compare mode, output toggle mode, IRQ enabled
188
        mov  #0x0060, &TACCR1
189
        mov  #0x0090, &TACCTL1  ; # Compare mode, output toggle mode, IRQ enabled
190
        mov  #0x0030, &TACCR2
191
        mov  #0x0090, &TACCTL2  ; # Compare mode, output toggle mode, IRQ enabled
192
        mov  #0x0002, &0x0200
193
        mov  #0x0277, &TACTL    ; # Up-down mode & clk/2, IRQ enabled
194
        mov  #0x00E0, r14
195
        call #WAIT_FUNC
196
 
197
 
198
        dint
199
        mov  #0x0000, &0x0200
200
        mov  #0x3000, r15
201
 
202
        /* --------------   TIMER A TEST:  CCI INPUT LATCHING (SCCI)  ----------------- */
203
 
204
        mov  #0x0200, &TACTL
205
        mov  #0x0000, &TACCTL0
206
        mov  #0x0000, &TACCTL1
207
        mov  #0x0000, &TACCTL2
208
        eint
209
 
210
                                ; # --------- UP-MODE - COMPARATOR 0 ----------
211
        mov  #0x0204, &TACTL
212
        mov  #0x0020, &TACCR0
213
        mov  #0x3080, &TACCTL0  ; # Compare mode, output toggle mode, select VCC input
214
        mov  #0x0000, &TACCR1
215
        mov  #0x0000, &TACCTL1  ; # Disabled
216
        mov  #0x0000, &TACCR2
217
        mov  #0x0000, &TACCTL2  ; # Disabled
218
        mov  #0x0001, &0x0200
219
        mov  #0x0254, &TACTL    ; # Up-mode & clk/2
220
 
221
comp0_check_0:                  ; # Wait until SCCI is set to 1
222
        mov       r5, &0x0202
223
        mov &TACCTL0, r5
224
        mov       r5, r4
225
        and  #0x0001, r4
226
        jz  comp0_check_0
227
        mov &TACCTL0, &0x0204
228
 
229
        mov  #0x2080, &TACCTL0  ; # Wait until SCCI is set back to 0
230
comp0_check_1:
231
        mov       r5, &0x0206
232
        mov &TACCTL0, r5
233
        mov       r5, r4
234
        and  #0x0001, r4
235
        jz  comp0_check_1
236
        mov &TACCTL0, &0x0208
237
 
238
 
239
                                ; # --------- UP-MODE - COMPARATOR 1 ----------
240
        mov  #0x0204, &TACTL
241
        mov  #0x0040, &TACCR0
242
        mov  #0x0000, &TACCTL0  ; # Disabled
243
        mov  #0x0020, &TACCR1
244
        mov  #0x3080, &TACCTL1  ; # Compare mode, output toggle mode, select VCC input
245
        mov  #0x0000, &TACCR2
246
        mov  #0x0000, &TACCTL2  ; # Disabled
247
        mov  #0x0002, &0x0200
248
        mov  #0x0254, &TACTL    ; # Up-mode & clk/2
249
 
250
comp1_check_0:                  ; # Wait until SCCI is set to 1
251
        mov       r5, &0x0212
252
        mov &TACCTL1, r5
253
        mov       r5, r4
254
        and  #0x0001, r4
255
        jz  comp1_check_0
256
        mov &TACCTL1, &0x0214
257
 
258
        mov  #0x2080, &TACCTL1  ; # Wait until SCCI is set back to 0
259
comp1_check_1:
260
        mov       r5, &0x0216
261
        mov &TACCTL1, r5
262
        mov       r5, r4
263
        and  #0x0001, r4
264
        jz  comp1_check_1
265
        mov &TACCTL1, &0x0218
266
 
267
 
268
                                ; # --------- UP-MODE - COMPARATOR 2 ----------
269
        mov  #0x0204, &TACTL
270
        mov  #0x0040, &TACCR0
271
        mov  #0x0000, &TACCTL0  ; # Disabled
272
        mov  #0x0000, &TACCR1
273
        mov  #0x0000, &TACCTL1  ; # Disabled
274
        mov  #0x0020, &TACCR2
275
        mov  #0x3080, &TACCTL2  ; # Compare mode, output toggle mode, select VCC input
276
        mov  #0x0003, &0x0200
277
        mov  #0x0254, &TACTL    ; # Up-mode & clk/2
278
 
279
comp2_check_0:                  ; # Wait until SCCI is set to 1
280
        mov       r5, &0x0222
281
        mov &TACCTL2, r5
282
        mov       r5, r4
283
        and  #0x0001, r4
284
        jz  comp2_check_0
285
        mov &TACCTL2, &0x0224
286
 
287
        mov  #0x2080, &TACCTL2  ; # Wait until SCCI is set back to 0
288
comp2_check_1:
289
        mov       r5, &0x0226
290
        mov &TACCTL2, r5
291
        mov       r5, r4
292
        and  #0x0001, r4
293
        jz  comp2_check_1
294
        mov &TACCTL2, &0x0228
295
 
296
 
297
        dint
298
        mov  #0x0000, &0x0200
299
        mov  #0x4000, r15
300
 
301
 
302
        /* ----------------------         END OF TEST        --------------- */
303
end_of_test:
304
        nop
305
        br #0xffff
306
 
307
 
308
        /* ----------------------      INTERRUPT ROUTINES    --------------- */
309
 
310
TIMERA_CCR0_VECTOR:
311
        mov     &TAR, &0x0202
312
        reti
313
 
314
 
315
TIMERA_TAIV_VECTOR:
316
        mov     &TAR, &0x0204
317
        mov    &TAIV, &0x0206
318
        reti
319
 
320
 
321
        /* ----------------------         INTERRUPT VECTORS  --------------- */
322
 
323
.section .vectors, "a"
324
.word end_of_test        ; Interrupt  0 (lowest priority)    
325
.word end_of_test        ; Interrupt  1                      
326
.word end_of_test        ; Interrupt  2                      
327
.word end_of_test        ; Interrupt  3                      
328
.word end_of_test        ; Interrupt  4                      
329
.word end_of_test        ; Interrupt  5                      
330
.word end_of_test        ; Interrupt  6                      
331
.word end_of_test        ; Interrupt  7                      
332
.word TIMERA_TAIV_VECTOR ; Interrupt  8                      
333
.word TIMERA_CCR0_VECTOR ; Interrupt  9                      
334
.word end_of_test        ; Interrupt 10                      Watchdog timer
335
.word end_of_test        ; Interrupt 11                      
336
.word end_of_test        ; Interrupt 12                      
337
.word end_of_test        ; Interrupt 13                      
338
.word end_of_test        ; Interrupt 14                      NMI
339
.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.