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

Subversion Repositories openmsp430

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 134 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
/*                                                                           */
29
/* Author(s):                                                                */
30
/*             - Olivier Girard,    olgirard@gmail.com                       */
31
/*                                                                           */
32
/*---------------------------------------------------------------------------*/
33
/* $Rev: 19 $                                                                */
34
/* $LastChangedBy: olivier.girard $                                          */
35
/* $LastChangedDate: 2009-08-04 23:47:15 +0200 (Tue, 04 Aug 2009) $          */
36
/*===========================================================================*/
37
/*                                                                           */
38
/* Low Power modes:                                                          */
39
/*                              - LPM0    <=>  CPUOFF                        */
40
/*                              - LPM1    <=>  CPUOFF + SCG0                 */
41
/*                              - LPM2    <=>  CPUOFF +        SCG1          */
42
/*                              - LPM3    <=>  CPUOFF + SCG0 + SCG1          */
43
/*                              - LPM4    <=>  CPUOFF + SCG0 + SCG1 + OSCOFF */
44
/*                                                                           */
45
/* Reminder:                                                                 */
46
/*                              - CPUOFF  <=>  turns off CPU.                */
47
/*                              - SCG0    <=>  turns off DCO.                */
48
/*                              - SCG1    <=>  turns off SMCLK.              */
49
/*                              - OSCOFF  <=>  turns off LFXT_CLK.           */
50
/*                                                                           */
51
/*---------------------------------------------------------------------------*/
52
 
53 141 olivier.gi
.include "pmem_defs.asm"
54
 
55 134 olivier.gi
.global main
56
 
57
.macro LPM0
58
 bis    #0x0010, r2
59
.endm
60
.macro LPM1
61
 bis    #0x0050, r2
62
.endm
63
.macro LPM2
64
 bis    #0x0090, r2
65
.endm
66
.macro LPM3
67
 bis    #0x00D0, r2
68
.endm
69
.macro LPM4
70
 bis    #0x00F0, r2
71
.endm
72
 
73
.macro LPM0_exit
74
 bic    #0x0010, @r1
75
.endm
76
.macro LPM1_exit
77
 bic    #0x0050, @r1
78
.endm
79
.macro LPM2_exit
80
 bic    #0x0090, @r1
81
.endm
82
.macro LPM3_exit
83
 bic    #0x00D0, @r1
84
.endm
85
.macro LPM4_exit
86
 bic    #0x00F0, @r1
87
.endm
88
 
89
 
90
main:
91
 
92
        /* --------------   WATCHDOG TEST:  WAKE-UP INTERVAL MODE   ------------ */
93
 
94
        mov   &IFG1, r4
95
        cmp #0x0001, &IFG1        ;# Check if we come out of a watchdog reset
96
        jeq   end_of_test
97
 
98
        mov   #DMEM_250, r1       ;# Initialize stack & Enable interrupts
99
        eint
100
        bis.b #0x01,   &IE1
101
 
102
        mov   #0x0000, r6
103
 
104
        mov   #0x5a1f, &WDTCTL	  ;# Enable interval mode /64 and select ACLK
105
 
106
        mov   &WDTCTL, r5	  ;# If ACLK is selected, go to LPM3... otherwhise go to LPM0
107
        bit   #0x0004, r5
108
        jnz   lpm3_test
109
   lpm0_test:
110
        mov   #0x1000, r15
111
        LPM0
112
        jmp   lpm_test_done
113
   lpm3_test:
114
        mov   #0x1000, r15
115
        LPM3
116
   lpm_test_done:
117
 
118
        /* --------------   WATCHDOG TEST:  WAKE-UP RESET MODE   ------------ */
119
 
120
        mov   #0x5a0f, &WDTCTL	  ;# Enable reset mode /64 and select ACLK
121
        mov   #0x5555, r7
122
 
123
        mov   &WDTCTL, r5	  ;# If ACLK is selected, go to LPM3... otherwhise go to LPM0
124
        bit   #0x0004, r5
125
        jnz   lpm3_rst_test
126
   lpm0_rst_test:
127
        mov   #0x1000, r15
128
        LPM0
129
        jmp   lpm_rst_test_done
130
   lpm3_rst_test:
131
        mov   #0x1000, r15
132
        LPM3
133
   lpm_rst_test_done:
134
 
135
 
136
        /* ----------------------         END OF TEST        --------------- */
137
end_of_test:
138
        mov   #0x5000, r15
139
        nop
140
        br #0xffff
141
 
142
 
143
        /* ----------------------      INTERRUPT ROUTINES    --------------- */
144
 
145
WDOG_VECTOR:
146
        inc    r6               ;# Increment counter variable
147
        cmp    #10, r6
148
        jl     end_of_irq
149
 
150
        mov   &WDTCTL, r5	;# If ACLK is selected, exit LPM3... otherwhise exit LPM0
151
        bit   #0x0004, r5
152
        jnz   lpm3_test_exit
153
   lpm0_test_exit:
154
        mov   #0x2000, r15
155
        LPM0_exit
156
        reti
157
   lpm3_test_exit:
158
        mov   #0x2000, r15
159
        LPM3_exit
160
 
161
   end_of_irq:
162
        mov   #0x6666, r7
163
        reti
164
 
165
 
166
 
167
        /* ----------------------         INTERRUPT VECTORS  --------------- */
168
 
169
.section .vectors, "a"
170
.word end_of_test  ; Interrupt  0 (lowest priority)    
171
.word end_of_test  ; Interrupt  1                      
172
.word end_of_test  ; Interrupt  2                      
173
.word end_of_test  ; Interrupt  3                      
174
.word end_of_test  ; Interrupt  4                      
175
.word end_of_test  ; Interrupt  5                      
176
.word end_of_test  ; Interrupt  6                      
177
.word end_of_test  ; Interrupt  7                      
178
.word end_of_test  ; Interrupt  8                      
179
.word end_of_test  ; Interrupt  9                      
180
.word WDOG_VECTOR  ; Interrupt 10                      Watchdog timer
181
.word end_of_test  ; Interrupt 11                      
182
.word end_of_test  ; Interrupt 12                      
183
.word end_of_test  ; Interrupt 13                      
184
.word end_of_test  ; Interrupt 14                      NMI
185
.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.