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

Subversion Repositories openmsp430

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

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
/*                            CPU OPERATING MODES                            */
25
/*---------------------------------------------------------------------------*/
26
/* Test the CPU Operating modes:                                             */
27
/*                                 - CPUOFF (<=> R2[4]): turn off CPU.       */
28
/*                                 - OSCOFF (<=> R2[5]): turn off LFXT_CLK.  */
29
/*                                 - SCG1   (<=> R2[7]): turn off SMCLK.     */
30 18 olivier.gi
/*                                                                           */
31
/* Author(s):                                                                */
32
/*             - Olivier Girard,    olgirard@gmail.com                       */
33
/*                                                                           */
34
/*---------------------------------------------------------------------------*/
35 19 olivier.gi
/* $Rev: 141 $                                                                */
36
/* $LastChangedBy: olivier.girard $                                          */
37
/* $LastChangedDate: 2012-05-05 23:22:06 +0200 (Sat, 05 May 2012) $          */
38 2 olivier.gi
/*===========================================================================*/
39
 
40 141 olivier.gi
.include "pmem_defs.asm"
41
 
42 2 olivier.gi
.global main
43
 
44
WAIT_FUNC:
45
        dec r14
46
        jnz WAIT_FUNC
47
        ret
48
 
49
main:
50
        ; Enable GPIO interrupts on P1[0]
51
        mov.b #0x00, &P1DIR
52
        mov.b #0x00, &P1IFG
53
        mov.b #0x00, &P1IES
54
        mov.b #0x01, &P1IE
55
 
56
        ; Initialize stack and enable global interrupts
57 111 olivier.gi
        mov   #DMEM_250, r1
58 2 olivier.gi
        eint
59
 
60 111 olivier.gi
        mov     #0x1000, r15
61 2 olivier.gi
 
62
 
63
        /* -------------- SCG1   (<=> R2[7]): turn off SMCLK --------------- */
64
 
65
        mov.b  #0x06, &BCSCTL2  ; # Div /8
66
 
67
        mov    #0x0008, r2      ; # SCG1=0 (SMCLK on)
68
        mov    #0x1001, r15
69
        mov    #0x0020, r14
70
        call   #WAIT_FUNC
71
 
72
        mov    #0x0088, r2      ; # SCG1=1 (SMCLK off)
73
        mov    #0x1002, r15
74
        mov    #0x0020, r14
75
        call   #WAIT_FUNC
76
 
77
        mov    #0x1003, r15      ; # SCG1=1 (SMCLK off) with IRQ
78
        mov    #0x0020, r14
79
        call   #WAIT_FUNC
80
 
81
        mov    #0x1004, r15      ; # SCG1=1 (SMCLK off) return from IRQ
82
        mov    #0x0020, r14
83
        call   #WAIT_FUNC
84
 
85
        mov    #0x0008, r2      ; # SCG1=0 (SMCLK on)
86
        mov    #0x1005, r15
87
        mov    #0x0020, r14
88
        call   #WAIT_FUNC
89
 
90
        mov     #0x2000, r15
91
 
92
 
93
        /* -------------- OSCOFF (<=> R2[5]): turn off LFXT1CLK --------------- */
94
 
95
        mov.b  #0x00, &BCSCTL2  ; # Div /1 --> select DCOCLK
96
        mov    #0x0008, r2      ; # OSCOFF=0 (LFXT1 on)
97
        mov    #0x2001, r15
98
        mov    #0x0050, r14
99
        call   #WAIT_FUNC
100
 
101
        mov.b  #0x00, &BCSCTL2  ; # Div /1 --> select DCOCLK
102
        mov    #0x0028, r2      ; # OSCOFF=1 (LFXT1 off)
103
        mov    #0x2002, r15
104
        mov    #0x0050, r14
105
        call   #WAIT_FUNC
106
 
107
        mov    #0x2003, r15      ; # OSCOFF=1 (LFXT1 off) with IRQ
108
        mov    #0x0050, r14
109
        call   #WAIT_FUNC
110
 
111
        mov    #0x2004, r15      ; # OSCOFF=1 (LFXT1 off) return from IRQ
112
        mov    #0x0050, r14
113
        call   #WAIT_FUNC
114
 
115
        mov.b  #0x08, &BCSCTL2  ; # Div /1 --> select LFXT1CLK
116
        mov    #0x0028, r2      ; # OSCOFF=1 (LFXT1 off)
117
        mov    #0x2005, r15
118
        mov    #0x0050, r14
119
        call   #WAIT_FUNC
120
 
121
        mov.b  #0x00, &BCSCTL2  ; # Div /1 --> select DCOCLK
122
        mov    #0x0008, r2      ; # OSCOFF=0 (LFXT1 on)
123
        mov    #0x2006, r15
124
        mov    #0x0050, r14
125
        call   #WAIT_FUNC
126
 
127
        mov     #0x3000, r15
128
 
129
 
130
        /* -------------- CPUOFF (<=> R2[4]): turn off CPU    --------------- */
131
 
132
        ; Enable GPIO interrupts on P2[0]
133
        mov.b #0x00, &P2DIR
134
        mov.b #0x00, &P2IFG
135
        mov.b #0x00, &P2IES
136
        mov.b #0x01, &P2IE
137
 
138
        mov.b  #0x00, &BCSCTL2  ; # Div /1 --> select DCOCLK
139
 
140
        mov    #0x3001, r15
141
        mov    #0x0008, r2      ; # CPUOFF=0 (CPU on)
142
        mov    #0x0020, r14
143
        call   #WAIT_FUNC
144
 
145
        mov    #0x3002, r15
146
        mov    #0x0018, r2      ; # CPUOFF=1 (CPU off)
147
        mov    #0x0020, r14
148
        call   #WAIT_FUNC
149
 
150
        mov    #0x3003, r15
151
        mov    #0x0008, r2      ; # CPUOFF=0 (CPU on)
152
        mov    #0x0020, r14
153
        call   #WAIT_FUNC
154
 
155
 
156
 
157
        /* ----------------------         END OF TEST        --------------- */
158
end_of_test:
159
        nop
160
        br #0xffff
161
 
162
 
163
        /* ----------------------      INTERRUPT ROUTINES    --------------- */
164
 
165
PORT1_VECTOR:
166
        push       r14
167
        mov    #0x0050, r14
168
        call   #WAIT_FUNC
169
        pop        r14
170
        mov.b #0x00, &P1IFG
171
        reti
172
 
173
PORT2_VECTOR:
174
        push       r14
175
        mov    #0x0050, r14
176
        call   #WAIT_FUNC
177
        pop        r14
178
        mov.b #0x00, &P2IFG
179
        bic    #0x10, 0(r1) ;exit lowpower mode
180
        reti
181
 
182
 
183
        /* ----------------------         INTERRUPT VECTORS  --------------- */
184
 
185
.section .vectors, "a"
186
.word end_of_test  ; Interrupt  0 (lowest priority)    
187
.word end_of_test  ; Interrupt  1                      
188
.word PORT1_VECTOR ; Interrupt  2                      
189
.word PORT2_VECTOR ; Interrupt  3                      
190
.word end_of_test  ; Interrupt  4                      
191
.word end_of_test  ; Interrupt  5                      
192
.word end_of_test  ; Interrupt  6                      
193
.word end_of_test  ; Interrupt  7                      
194
.word end_of_test  ; Interrupt  8                      
195
.word end_of_test  ; Interrupt  9                      
196
.word end_of_test  ; Interrupt 10                      Watchdog timer
197
.word end_of_test  ; Interrupt 11                      
198
.word end_of_test  ; Interrupt 12                      
199
.word end_of_test  ; Interrupt 13                      
200
.word end_of_test  ; Interrupt 14                      NMI
201
.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.