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

Subversion Repositories openmsp430

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

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
/*                        - Watchdog mode.                                   */
28 17 olivier.gi
/*                                                                           */
29 18 olivier.gi
/* Author(s):                                                                */
30
/*             - Olivier Girard,    olgirard@gmail.com                       */
31
/*                                                                           */
32 17 olivier.gi
/*---------------------------------------------------------------------------*/
33
/* $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_250,  (__data_start+0x50)
47
 
48 2 olivier.gi
.set   IE1,    0x0000
49
.set   IFG1,   0x0002
50
.set   WDTCTL, 0x0120
51
 
52
 
53
main:
54
 
55
        /* --------------   WATCHDOG TEST:  STARTUP SEQUENCE  --------------- */
56
 
57
        mov   &IFG1, r4       	;# Check if we come out of a watchdog reset
58
        cmp #0x0000, r4
59
        jeq   RD_WR_ACCESS
60
 
61 111 olivier.gi
        mov &DMEM_250, r15        ;# If yes, check RAM variable to see where to go next
62 2 olivier.gi
 
63
        cmp #0x0000, r15
64
        jeq   RESET_64
65
        cmp #0x1000, r15
66
        jeq   RESET_512
67
        cmp #0x2000, r15
68
        jeq   RESET_8192
69
        cmp #0x3000, r15
70
        jeq   RESET_32768
71
        cmp #0x4000, r15
72
        jeq   CHECK_32768
73
 
74
        jmp  end_of_test
75
 
76
 
77
        /* --------------   WATCHDOG TEST:  RD/WR ACCESS    --------------- */
78
RD_WR_ACCESS:
79 111 olivier.gi
        mov  #0x0000, &DMEM_250
80 2 olivier.gi
 
81 111 olivier.gi
        mov  &WDTCTL, &DMEM_200
82 2 olivier.gi
        mov  #0x5aff, &WDTCTL
83 111 olivier.gi
        mov  &WDTCTL, &DMEM_202
84 2 olivier.gi
        mov  #0x5a55, &WDTCTL
85 111 olivier.gi
        mov  &WDTCTL, &DMEM_204
86 2 olivier.gi
        mov  #0x5aaa, &WDTCTL
87 111 olivier.gi
        mov  &WDTCTL, &DMEM_206
88 2 olivier.gi
        mov  #0x5a00, &WDTCTL
89 111 olivier.gi
        mov  &WDTCTL, &DMEM_208
90 2 olivier.gi
 
91
        mov  #0xDEAD, &WDTCTL	 ;# Generate reset through wrong password
92
 
93
        jmp  end_of_test         ;# Force end of test if watchdog reset don't happen
94
 
95
 
96
 
97
        /* --------------   WATCHDOG TEST:  WATCHODG MODE /64  ------------ */
98
RESET_64:
99
        bic.b #0x01,   &IFG1
100 111 olivier.gi
        mov   #0x1000, &DMEM_250
101 2 olivier.gi
 
102
        mov   #0x5a0b, &WDTCTL	 ;# Enable watchdog mode /64 & clear counter
103
 
104 111 olivier.gi
        mov   #0x0000, &DMEM_200
105 2 olivier.gi
wait_loop_64:
106 111 olivier.gi
        inc   &DMEM_200
107 2 olivier.gi
        jmp   wait_loop_64
108
 
109
        jmp   end_of_test        ;# Force end of test if watchdog reset don't happen
110
 
111
 
112
 
113
        /* --------------   WATCHDOG TEST:  INTERVAL MODE /512  ------------ */
114
RESET_512:
115
        bic.b #0x01,   &IFG1
116 111 olivier.gi
        mov   #0x2000, &DMEM_250
117 2 olivier.gi
 
118
        mov   #0x5a0a, &WDTCTL	  ;# Enable watchdog mode /512 & clear counter
119
 
120 111 olivier.gi
        mov   #0x0000, &DMEM_202
121 2 olivier.gi
wait_loop_512:
122 111 olivier.gi
        inc   &DMEM_202
123 2 olivier.gi
        jmp   wait_loop_512
124
 
125
        jmp   end_of_test         ;# Force end of test if watchdog reset don't happen
126
 
127
 
128
 
129
        /* --------------   WATCHDOG TEST:  INTERVAL MODE /8192  ------------ */
130
RESET_8192:
131
        bic.b #0x01,   &IFG1
132 111 olivier.gi
        mov   #0x3000, &DMEM_250
133 2 olivier.gi
 
134
        mov   #0x5a09, &WDTCTL	  ;# Enable watchdog mode /8192 & clear counter
135
 
136 111 olivier.gi
        mov   #0x0000, &DMEM_204
137 2 olivier.gi
wait_loop_8192:
138 111 olivier.gi
        inc   &DMEM_204
139 2 olivier.gi
        jmp   wait_loop_8192
140
 
141
        jmp   end_of_test         ;# Force end of test if watchdog reset don't happen
142
 
143
 
144
 
145
        /* --------------   WATCHDOG TEST:  INTERVAL MODE /32768  ------------ */
146
RESET_32768:
147
        bic.b #0x01,   &IFG1
148 111 olivier.gi
        mov   #0x4000, &DMEM_250
149 2 olivier.gi
 
150
        mov   #0x5a08, &WDTCTL	  ;# Enable interval mode /32768 & clear counter
151
 
152 111 olivier.gi
        mov   #0x0000, &DMEM_206
153 2 olivier.gi
wait_loop_32768:
154 111 olivier.gi
        inc   &DMEM_206
155 2 olivier.gi
        jmp   wait_loop_32768
156
 
157
        jmp   end_of_test         ;# Force end of test if watchdog reset don't happen
158
 
159
 
160
CHECK_32768:
161
        bic.b #0x01,   &IFG1
162 111 olivier.gi
        mov   #0x5000, &DMEM_250
163 2 olivier.gi
 
164
 
165
        /* ----------------------         END OF TEST        --------------- */
166
end_of_test:
167
        nop
168
        br #0xffff
169
 
170
 
171
        /* ----------------------      INTERRUPT ROUTINES    --------------- */
172
 
173
WDOG_VECTOR:
174
        bis  #0x3400, r5
175
        mov    &IFG1, r6
176
        mov       r4, r7
177
        reti
178
 
179
 
180
        /* ----------------------         INTERRUPT VECTORS  --------------- */
181
 
182
.section .vectors, "a"
183
.word end_of_test  ; Interrupt  0 (lowest priority)    
184
.word end_of_test  ; Interrupt  1                      
185
.word end_of_test  ; Interrupt  2                      
186
.word end_of_test  ; Interrupt  3                      
187
.word end_of_test  ; Interrupt  4                      
188
.word end_of_test  ; Interrupt  5                      
189
.word end_of_test  ; Interrupt  6                      
190
.word end_of_test  ; Interrupt  7                      
191
.word end_of_test  ; Interrupt  8                      
192
.word end_of_test  ; Interrupt  9                      
193
.word WDOG_VECTOR  ; Interrupt 10                      Watchdog timer
194
.word end_of_test  ; Interrupt 11                      
195
.word end_of_test  ; Interrupt 12                      
196
.word end_of_test  ; Interrupt 13                      
197
.word end_of_test  ; Interrupt 14                      NMI
198
.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.