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 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
/*                            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: 111 $                                                                */
36
/* $LastChangedBy: olivier.girard $                                          */
37
/* $LastChangedDate: 2011-05-20 22:39:02 +0200 (Fri, 20 May 2011) $          */
38 2 olivier.gi
/*===========================================================================*/
39
 
40
.global main
41
 
42 111 olivier.gi
.set   DMEM_BASE, (__data_start     )
43
.set   DMEM_200,  (__data_start+0x00)
44
.set   DMEM_250,  (__data_start+0x50)
45
 
46 2 olivier.gi
.set   P1IN,  0x0020
47
.set   P1OUT, 0x0021
48
.set   P1DIR, 0x0022
49
.set   P1IFG, 0x0023
50
.set   P1IES, 0x0024
51
.set   P1IE,  0x0025
52
.set   P1SEL, 0x0026
53
.set   P2IN,  0x0028
54
.set   P2OUT, 0x0029
55
.set   P2DIR, 0x002A
56
.set   P2IFG, 0x002B
57
.set   P2IES, 0x002C
58
.set   P2IE,  0x002D
59
.set   P2SEL, 0x002E
60
 
61
.set   BCSCTL1, 0x0057
62
.set   BCSCTL2, 0x0058
63
 
64
 
65
WAIT_FUNC:
66
        dec r14
67
        jnz WAIT_FUNC
68
        ret
69
 
70
main:
71
        ; Enable GPIO interrupts on P1[0]
72
        mov.b #0x00, &P1DIR
73
        mov.b #0x00, &P1IFG
74
        mov.b #0x00, &P1IES
75
        mov.b #0x01, &P1IE
76
 
77
        ; Initialize stack and enable global interrupts
78 111 olivier.gi
        mov   #DMEM_250, r1
79 2 olivier.gi
        eint
80
 
81 111 olivier.gi
        mov     #0x1000, r15
82 2 olivier.gi
 
83
 
84
        /* -------------- SCG1   (<=> R2[7]): turn off SMCLK --------------- */
85
 
86
        mov.b  #0x06, &BCSCTL2  ; # Div /8
87
 
88
        mov    #0x0008, r2      ; # SCG1=0 (SMCLK on)
89
        mov    #0x1001, r15
90
        mov    #0x0020, r14
91
        call   #WAIT_FUNC
92
 
93
        mov    #0x0088, r2      ; # SCG1=1 (SMCLK off)
94
        mov    #0x1002, r15
95
        mov    #0x0020, r14
96
        call   #WAIT_FUNC
97
 
98
        mov    #0x1003, r15      ; # SCG1=1 (SMCLK off) with IRQ
99
        mov    #0x0020, r14
100
        call   #WAIT_FUNC
101
 
102
        mov    #0x1004, r15      ; # SCG1=1 (SMCLK off) return from IRQ
103
        mov    #0x0020, r14
104
        call   #WAIT_FUNC
105
 
106
        mov    #0x0008, r2      ; # SCG1=0 (SMCLK on)
107
        mov    #0x1005, r15
108
        mov    #0x0020, r14
109
        call   #WAIT_FUNC
110
 
111
        mov     #0x2000, r15
112
 
113
 
114
        /* -------------- OSCOFF (<=> R2[5]): turn off LFXT1CLK --------------- */
115
 
116
        mov.b  #0x00, &BCSCTL2  ; # Div /1 --> select DCOCLK
117
        mov    #0x0008, r2      ; # OSCOFF=0 (LFXT1 on)
118
        mov    #0x2001, r15
119
        mov    #0x0050, r14
120
        call   #WAIT_FUNC
121
 
122
        mov.b  #0x00, &BCSCTL2  ; # Div /1 --> select DCOCLK
123
        mov    #0x0028, r2      ; # OSCOFF=1 (LFXT1 off)
124
        mov    #0x2002, r15
125
        mov    #0x0050, r14
126
        call   #WAIT_FUNC
127
 
128
        mov    #0x2003, r15      ; # OSCOFF=1 (LFXT1 off) with IRQ
129
        mov    #0x0050, r14
130
        call   #WAIT_FUNC
131
 
132
        mov    #0x2004, r15      ; # OSCOFF=1 (LFXT1 off) return from IRQ
133
        mov    #0x0050, r14
134
        call   #WAIT_FUNC
135
 
136
        mov.b  #0x08, &BCSCTL2  ; # Div /1 --> select LFXT1CLK
137
        mov    #0x0028, r2      ; # OSCOFF=1 (LFXT1 off)
138
        mov    #0x2005, r15
139
        mov    #0x0050, r14
140
        call   #WAIT_FUNC
141
 
142
        mov.b  #0x00, &BCSCTL2  ; # Div /1 --> select DCOCLK
143
        mov    #0x0008, r2      ; # OSCOFF=0 (LFXT1 on)
144
        mov    #0x2006, r15
145
        mov    #0x0050, r14
146
        call   #WAIT_FUNC
147
 
148
        mov     #0x3000, r15
149
 
150
 
151
        /* -------------- CPUOFF (<=> R2[4]): turn off CPU    --------------- */
152
 
153
        ; Enable GPIO interrupts on P2[0]
154
        mov.b #0x00, &P2DIR
155
        mov.b #0x00, &P2IFG
156
        mov.b #0x00, &P2IES
157
        mov.b #0x01, &P2IE
158
 
159
        mov.b  #0x00, &BCSCTL2  ; # Div /1 --> select DCOCLK
160
 
161
        mov    #0x3001, r15
162
        mov    #0x0008, r2      ; # CPUOFF=0 (CPU on)
163
        mov    #0x0020, r14
164
        call   #WAIT_FUNC
165
 
166
        mov    #0x3002, r15
167
        mov    #0x0018, r2      ; # CPUOFF=1 (CPU off)
168
        mov    #0x0020, r14
169
        call   #WAIT_FUNC
170
 
171
        mov    #0x3003, r15
172
        mov    #0x0008, r2      ; # CPUOFF=0 (CPU on)
173
        mov    #0x0020, r14
174
        call   #WAIT_FUNC
175
 
176
 
177
 
178
        /* ----------------------         END OF TEST        --------------- */
179
end_of_test:
180
        nop
181
        br #0xffff
182
 
183
 
184
        /* ----------------------      INTERRUPT ROUTINES    --------------- */
185
 
186
PORT1_VECTOR:
187
        push       r14
188
        mov    #0x0050, r14
189
        call   #WAIT_FUNC
190
        pop        r14
191
        mov.b #0x00, &P1IFG
192
        reti
193
 
194
PORT2_VECTOR:
195
        push       r14
196
        mov    #0x0050, r14
197
        call   #WAIT_FUNC
198
        pop        r14
199
        mov.b #0x00, &P2IFG
200
        bic    #0x10, 0(r1) ;exit lowpower mode
201
        reti
202
 
203
 
204
        /* ----------------------         INTERRUPT VECTORS  --------------- */
205
 
206
.section .vectors, "a"
207
.word end_of_test  ; Interrupt  0 (lowest priority)    
208
.word end_of_test  ; Interrupt  1                      
209
.word PORT1_VECTOR ; Interrupt  2                      
210
.word PORT2_VECTOR ; Interrupt  3                      
211
.word end_of_test  ; Interrupt  4                      
212
.word end_of_test  ; Interrupt  5                      
213
.word end_of_test  ; Interrupt  6                      
214
.word end_of_test  ; Interrupt  7                      
215
.word end_of_test  ; Interrupt  8                      
216
.word end_of_test  ; Interrupt  9                      
217
.word end_of_test  ; Interrupt 10                      Watchdog timer
218
.word end_of_test  ; Interrupt 11                      
219
.word end_of_test  ; Interrupt 12                      
220
.word end_of_test  ; Interrupt 13                      
221
.word end_of_test  ; Interrupt 14                      NMI
222
.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.