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 141

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