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

Subversion Repositories openmsp430

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

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
/*                            WATCHDOG TIMER                                 */
25
/*---------------------------------------------------------------------------*/
26
/* Test the Watdog timer:                                                    */
27
/*                        - Interval timer mode.                             */
28 18 olivier.gi
/*                                                                           */
29
/* Author(s):                                                                */
30
/*             - Olivier Girard,    olgirard@gmail.com                       */
31
/*                                                                           */
32
/*---------------------------------------------------------------------------*/
33 19 olivier.gi
/* $Rev: 134 $                                                                */
34
/* $LastChangedBy: olivier.girard $                                          */
35
/* $LastChangedDate: 2012-03-22 21:31:06 +0100 (Thu, 22 Mar 2012) $          */
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_250,  (__data_start+0x50)
43
 
44 2 olivier.gi
.set   IE1,    0x0000
45
.set   IFG1,   0x0002
46
.set   WDTCTL, 0x0120
47
 
48
 
49
main:
50
 
51
        /* --------------   WATCHDOG TEST:  RD/WR ACCESS    --------------- */
52
 
53 134 olivier.gi
        mov   &WDTCTL, r4
54
        mov   #0x5aff, &WDTCTL
55
        mov   &WDTCTL, r5
56
        mov   #0x5a55, &WDTCTL
57
        mov   &WDTCTL, r6
58
        mov   #0x5aaa, &WDTCTL
59
        mov   &WDTCTL, r7
60
        mov   #0x5a00, &WDTCTL
61
        mov   &WDTCTL, r8
62
        mov   &IFG1,   r9
63
        mov.b #0x00,   &IFG1
64 2 olivier.gi
 
65
        mov  #0x1000, r15
66
 
67
 
68
        /* --------------   WATCHDOG TEST:  INTERVAL MODE /64  ------------ */
69
 
70 111 olivier.gi
        mov   #DMEM_250, r1       ;# Initialize stack & Enable interrupts
71 2 olivier.gi
        eint
72
        bis.b #0x01,   &IE1
73
 
74
        mov   #0x5a1b, &WDTCTL	  ;# Enable interval mode /64 & clear counter
75
 
76
        mov   #0x0000, r4
77
        mov   #0x0001, r5
78
wait_loop_64:
79
        inc   r4
80
        cmp   #0x3401, r5
81
        jne   wait_loop_64
82
 
83
        mov   #0x2000, r15
84
 
85
 
86
 
87
        bic.b #0x01,   &IE1	  ;# Disable watchdog interrupt
88
 
89 134 olivier.gi
        mov   #0x0205, r4
90
        mov   &WDTCTL, r5	  ;# Check if ACLK is selected
91
        bit   #0x0004, r5
92
        jnz   aclk_sel_64
93
        mov   #0x0012, r4
94
   aclk_sel_64:
95
 
96 2 olivier.gi
        mov   #0x5a1b, &WDTCTL	  ;# Enable interval mode /64 & clear counter
97 134 olivier.gi
        mov   #0x0002, r5
98 2 olivier.gi
 
99
wait_loop_64_no_irq:
100
        dec   r4
101
        cmp   #0x0000, r4
102
        jne   wait_loop_64_no_irq
103
 
104
        mov    &IFG1, r6
105
        mov       r4, r7
106
        bic.b #0x01,   &IFG1	  ;# Clear flag
107
        mov    &IFG1, r8
108
 
109
        mov   #0x2001, r15
110
 
111
 
112
        mov   #0x5a9b, &WDTCTL	  ;# Enable interval mode /64 & clear counter & enable hold
113
 
114
        mov   #0x0020, r4
115
        mov   #0x0022, r5
116
wait_loop_64_no_irq_hold:
117
        dec   r4
118
        cmp   #0x0000, r4
119
        jne   wait_loop_64_no_irq_hold
120
 
121
        mov    &IFG1, r6
122
        mov       r4, r7
123
 
124
        mov   #0x2002, r15
125
 
126
 
127
 
128
        mov   #0x5a1b, &WDTCTL	  ;# Enable interval mode /64 & clear counter / Check counter clear
129
        mov   #0x0033, r4
130
 
131
        mov   #0x000C, r5
132
wait_loop_64_no_irq_clear1:
133
        dec   r5
134
        cmp   #0x0000, r5
135
        jne   wait_loop_64_no_irq_clear1
136
 
137
        mov   #0x5a1b, &WDTCTL	  ;# Clear counter
138
        mov    &IFG1, r6
139
 
140
        mov   #0x000C, r5
141
wait_loop_64_no_irq_clear2:
142
        dec   r5
143
        cmp   #0x0000, r5
144
        jne   wait_loop_64_no_irq_clear2
145
 
146
        mov    &IFG1, r7	  ;# Don't Clear counter
147
 
148
        mov   #0x000C, r5
149
wait_loop_64_no_irq_clear3:
150
        dec   r5
151
        cmp   #0x0000, r5
152
        jne   wait_loop_64_no_irq_clear3
153
 
154
        mov    &IFG1,   r8
155
        bic.b  #0x01,   &IFG1	  ;# Clear flag
156
 
157
 
158
        mov   #0x2003, r15
159
 
160
 
161
        /* --------------   WATCHDOG TEST:  INTERVAL MODE /512  ------------ */
162
 
163 111 olivier.gi
        mov   #DMEM_250, r1       ;# Initialize stack & Enable interrupts
164 2 olivier.gi
        eint
165
        bis.b #0x01,   &IE1
166
 
167
        mov   #0x5a1a, &WDTCTL	  ;# Enable interval mode /512 & clear counter
168
 
169
        mov   #0x0000, r4
170
        mov   #0x0003, r5
171
wait_loop_512:
172
        inc   r4
173
        cmp   #0x3403, r5
174
        jne   wait_loop_512
175
 
176
        mov   #0x3000, r15
177
 
178
 
179
        /* --------------   WATCHDOG TEST:  INTERVAL MODE /8192  ------------ */
180
 
181 111 olivier.gi
        mov   #DMEM_250, r1       ;# Initialize stack & Enable interrupts
182 2 olivier.gi
        eint
183
        bis.b #0x01,   &IE1
184
 
185
        mov   #0x5a19, &WDTCTL	  ;# Enable interval mode /8192 & clear counter
186
 
187
        mov   #0x0000, r4
188
        mov   #0x0004, r5
189
wait_loop_8192:
190
        inc   r4
191
        cmp   #0x3404, r5
192
        jne   wait_loop_8192
193
 
194
        mov   #0x4000, r15
195
 
196
 
197
 
198
        /* --------------   WATCHDOG TEST:  INTERVAL MODE /32768  ------------ */
199
 
200 111 olivier.gi
        mov   #DMEM_250, r1       ;# Initialize stack & Enable interrupts
201 2 olivier.gi
        eint
202
        bis.b #0x01,   &IE1
203
 
204
        mov   #0x5a18, &WDTCTL	  ;# Enable interval mode /32768 & clear counter
205
 
206
        mov   #0x0000, r4
207
        mov   #0x0005, r5
208
wait_loop_32768:
209
        inc   r4
210
        cmp   #0x3405, r5
211
        jne   wait_loop_32768
212
 
213
        mov   #0x5000, r15
214
 
215
 
216
 
217
 
218
        /* ----------------------         END OF TEST        --------------- */
219
end_of_test:
220
        nop
221
        br #0xffff
222
 
223
 
224
        /* ----------------------      INTERRUPT ROUTINES    --------------- */
225
 
226
WDOG_VECTOR:
227
        bis  #0x3400, r5
228
        mov    &IFG1, r6
229
        mov       r4, r7
230
        reti
231
 
232
 
233
        /* ----------------------         INTERRUPT VECTORS  --------------- */
234
 
235
.section .vectors, "a"
236
.word end_of_test  ; Interrupt  0 (lowest priority)    
237
.word end_of_test  ; Interrupt  1                      
238
.word end_of_test  ; Interrupt  2                      
239
.word end_of_test  ; Interrupt  3                      
240
.word end_of_test  ; Interrupt  4                      
241
.word end_of_test  ; Interrupt  5                      
242
.word end_of_test  ; Interrupt  6                      
243
.word end_of_test  ; Interrupt  7                      
244
.word end_of_test  ; Interrupt  8                      
245
.word end_of_test  ; Interrupt  9                      
246
.word WDOG_VECTOR  ; Interrupt 10                      Watchdog timer
247
.word end_of_test  ; Interrupt 11                      
248
.word end_of_test  ; Interrupt 12                      
249
.word end_of_test  ; Interrupt 13                      
250
.word end_of_test  ; Interrupt 14                      NMI
251
.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.