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 122

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