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

Subversion Repositories openmsp430

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

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
/*                            DIGITAL I/O                                    */
25
/*---------------------------------------------------------------------------*/
26
/* Test the Digital I/O interface:                                           */
27
/*                                   - Read/Write register access.           */
28
/*                                   - I/O Functionality.                    */
29 18 olivier.gi
/*                                                                           */
30
/* Author(s):                                                                */
31
/*             - Olivier Girard,    olgirard@gmail.com                       */
32
/*                                                                           */
33
/*---------------------------------------------------------------------------*/
34 19 olivier.gi
/* $Rev: 79 $                                                                */
35
/* $LastChangedBy: olivier.girard $                                          */
36
/* $LastChangedDate: 2010-11-23 20:36:16 +0100 (Tue, 23 Nov 2010) $          */
37 2 olivier.gi
/*===========================================================================*/
38
 
39
.global main
40
 
41
.set   P1IN,  0x0020
42
.set   P1OUT, 0x0021
43
.set   P1DIR, 0x0022
44
.set   P1IFG, 0x0023
45
.set   P1IES, 0x0024
46
.set   P1IE,  0x0025
47
.set   P1SEL, 0x0026
48
.set   P2IN,  0x0028
49
.set   P2OUT, 0x0029
50
.set   P2DIR, 0x002A
51
.set   P2IFG, 0x002B
52
.set   P2IES, 0x002C
53
.set   P2IE,  0x002D
54
.set   P2SEL, 0x002E
55
.set   P3IN,  0x0018
56
.set   P3OUT, 0x0019
57
.set   P3DIR, 0x001A
58
.set   P3SEL, 0x001B
59
.set   P4IN,  0x001C
60
.set   P4OUT, 0x001D
61
.set   P4DIR, 0x001E
62
.set   P4SEL, 0x001F
63
.set   P5IN,  0x0030
64
.set   P5OUT, 0x0031
65
.set   P5DIR, 0x0032
66
.set   P5SEL, 0x0033
67
.set   P6IN,  0x0034
68
.set   P6OUT, 0x0035
69
.set   P6DIR, 0x0036
70
.set   P6SEL, 0x0037
71
 
72
main:
73
        /* -------------- PORT 1: TEST RD/WR REGISTER ACCESS --------------- */
74
 
75
        mov.b #0xaa,  &P1IN          ; P1IN
76
        mov.b &P1IN,  &0x0200
77
        mov.b #0x55,  &P1IN
78
        mov.b &P1IN,  &0x0201
79
 
80
        mov.b #0xaa,  &P1OUT         ; P1OUT
81
        mov.b &P1OUT, &0x0202
82
        mov.b #0x55,  &P1OUT
83
        mov.b &P1OUT, &0x0203
84
 
85
        mov.b #0x5a,  &P1DIR         ; P1DIR
86
        mov.b &P1DIR, &0x0204
87
        mov.b #0xa5,  &P1DIR
88
        mov.b &P1DIR, &0x0205
89
 
90
        mov.b #0x55,  &P1IFG         ; P1IFG
91
        mov.b &P1IFG, &0x0206
92
        mov.b #0xaa,  &P1IFG
93
        mov.b &P1IFG, &0x0207
94
 
95
        mov.b #0xa5,  &P1IES         ; P1IES
96
        mov.b &P1IES, &0x0208
97
        mov.b #0x5a,  &P1IES
98
        mov.b &P1IES, &0x0209
99
 
100
        mov.b #0xaa,  &P1IE          ; P1IE
101
        mov.b &P1IE,  &0x020A
102
        mov.b #0x55,  &P1IE
103
        mov.b &P1IE,  &0x020B
104
 
105
        mov.b #0xcd,  &P1SEL         ; P1SEL
106
        mov.b &P1SEL, &0x020C
107
        mov.b #0x32,  &P1SEL
108
        mov.b &P1SEL, &0x020D
109
 
110
 
111
        mov.b #0x00,  &P1IN          ; Re-Initialize
112
        mov.b #0x00,  &P1OUT
113
        mov.b #0x00,  &P1DIR
114
        mov.b #0x00,  &P1IFG
115
        mov.b #0x00,  &P1IES
116
        mov.b #0x00,  &P1IE
117
        mov.b #0x00,  &P1SEL
118
 
119
        mov   #0x0001, r15
120
 
121
 
122
        /* -------------- PORT 2: TEST RD/WR REGISTER ACCESS --------------- */
123
 
124
        mov.b #0xaa,  &P2IN          ; P2IN
125
        mov.b &P2IN,  &0x0210
126
        mov.b #0x55,  &P2IN
127
        mov.b &P2IN,  &0x0211
128
 
129
        mov.b #0xaa,  &P2OUT         ; P2OUT
130
        mov.b &P2OUT, &0x0212
131
        mov.b #0x55,  &P2OUT
132
        mov.b &P2OUT, &0x0213
133
 
134
        mov.b #0x5a,  &P2DIR         ; P2DIR
135
        mov.b &P2DIR, &0x0214
136
        mov.b #0xa5,  &P2DIR
137
        mov.b &P2DIR, &0x0215
138
 
139
        mov.b #0x55,  &P2IFG         ; P2IFG
140
        mov.b &P2IFG, &0x0216
141
        mov.b #0xaa,  &P2IFG
142
        mov.b &P2IFG, &0x0217
143
 
144
        mov.b #0xa5,  &P2IES         ; P2IES
145
        mov.b &P2IES, &0x0218
146
        mov.b #0x5a,  &P2IES
147
        mov.b &P2IES, &0x0219
148
 
149
        mov.b #0xaa,  &P2IE          ; P2IE
150
        mov.b &P2IE,  &0x021A
151
        mov.b #0x55,  &P2IE
152
        mov.b &P2IE,  &0x021B
153
 
154
        mov.b #0xcd,  &P2SEL         ; P2SEL
155
        mov.b &P2SEL, &0x021C
156
        mov.b #0x32,  &P2SEL
157
        mov.b &P2SEL, &0x021D
158
 
159
        mov.b #0x00,  &P2IN          ; Re-Initialize
160
        mov.b #0x00,  &P2OUT
161
        mov.b #0x00,  &P2DIR
162
        mov.b #0x00,  &P2IFG
163
        mov.b #0x00,  &P2IES
164
        mov.b #0x00,  &P2IE
165
        mov.b #0x00,  &P2SEL
166
 
167
        mov   #0x0002, r15
168
 
169
 
170
        /* -------------- PORT 3: TEST RD/WR REGISTER ACCESS --------------- */
171
 
172
        mov.b #0xaa,  &P3IN          ; P3IN
173
        mov.b &P3IN,  &0x0220
174
        mov.b #0x55,  &P3IN
175
        mov.b &P3IN,  &0x0221
176
 
177
        mov.b #0xaa,  &P3OUT         ; P3OUT
178
        mov.b &P3OUT, &0x0222
179
        mov.b #0x55,  &P3OUT
180
        mov.b &P3OUT, &0x0223
181
 
182
        mov.b #0x5a,  &P3DIR         ; P3DIR
183
        mov.b &P3DIR, &0x0224
184
        mov.b #0xa5,  &P3DIR
185
        mov.b &P3DIR, &0x0225
186
 
187
        mov.b #0xcd,  &P3SEL         ; P3SEL
188
        mov.b &P3SEL, &0x0226
189
        mov.b #0x32,  &P3SEL
190
        mov.b &P3SEL, &0x0227
191
 
192
        mov.b #0x00,  &P3IN          ; Re-Initialize
193
        mov.b #0x00,  &P3OUT
194
        mov.b #0x00,  &P3DIR
195
        mov.b #0x00,  &P3SEL
196
 
197
        mov   #0x0003, r15
198
 
199
 
200
        /* -------------- PORT 4: TEST RD/WR REGISTER ACCESS --------------- */
201
 
202
        mov.b #0xaa,  &P4IN          ; P4IN
203
        mov.b &P4IN,  &0x0230
204
        mov.b #0x55,  &P4IN
205
        mov.b &P4IN,  &0x0231
206
 
207
        mov.b #0xaa,  &P4OUT         ; P4OUT
208
        mov.b &P4OUT, &0x0232
209
        mov.b #0x55,  &P4OUT
210
        mov.b &P4OUT, &0x0233
211
 
212
        mov.b #0x5a,  &P4DIR         ; P4DIR
213
        mov.b &P4DIR, &0x0234
214
        mov.b #0xa5,  &P4DIR
215
        mov.b &P4DIR, &0x0235
216
 
217
        mov.b #0xcd,  &P4SEL         ; P4SEL
218
        mov.b &P4SEL, &0x0236
219
        mov.b #0x32,  &P4SEL
220
        mov.b &P4SEL, &0x0237
221
 
222
        mov.b #0x00,  &P4IN          ; Re-Initialize
223
        mov.b #0x00,  &P4OUT
224
        mov.b #0x00,  &P4DIR
225
        mov.b #0x00,  &P4SEL
226
 
227
        mov   #0x0004, r15
228
 
229
 
230
        /* -------------- PORT 5: TEST RD/WR REGISTER ACCESS --------------- */
231
 
232
        mov.b #0xaa,  &P5IN          ; P5IN
233
        mov.b &P5IN,  &0x0240
234
        mov.b #0x55,  &P5IN
235
        mov.b &P5IN,  &0x0241
236
 
237
        mov.b #0xaa,  &P5OUT         ; P5OUT
238
        mov.b &P5OUT, &0x0242
239
        mov.b #0x55,  &P5OUT
240
        mov.b &P5OUT, &0x0243
241
 
242
        mov.b #0x5a,  &P5DIR         ; P5DIR
243
        mov.b &P5DIR, &0x0244
244
        mov.b #0xa5,  &P5DIR
245
        mov.b &P5DIR, &0x0245
246
 
247
        mov.b #0xcd,  &P5SEL         ; P5SEL
248
        mov.b &P5SEL, &0x0246
249
        mov.b #0x32,  &P5SEL
250
        mov.b &P5SEL, &0x0247
251
 
252
        mov.b #0x00,  &P5IN          ; Re-Initialize
253
        mov.b #0x00,  &P5OUT
254
        mov.b #0x00,  &P5DIR
255
        mov.b #0x00,  &P5SEL
256
 
257
        mov   #0x0005, r15
258
 
259
 
260
        /* -------------- PORT 6: TEST RD/WR REGISTER ACCESS --------------- */
261
 
262
        mov.b #0xaa,  &P6IN          ; P6IN
263
        mov.b &P6IN,  &0x0250
264
        mov.b #0x55,  &P6IN
265
        mov.b &P6IN,  &0x0251
266
 
267
        mov.b #0xaa,  &P6OUT         ; P6OUT
268
        mov.b &P6OUT, &0x0252
269
        mov.b #0x55,  &P6OUT
270
        mov.b &P6OUT, &0x0253
271
 
272
        mov.b #0x5a,  &P6DIR         ; P6DIR
273
        mov.b &P6DIR, &0x0254
274
        mov.b #0xa5,  &P6DIR
275
        mov.b &P6DIR, &0x0255
276
 
277
        mov.b #0xcd,  &P6SEL         ; P6SEL
278
        mov.b &P6SEL, &0x0256
279
        mov.b #0x32,  &P6SEL
280
        mov.b &P6SEL, &0x0257
281
 
282
        mov.b #0x00,  &P6IN          ; Re-Initialize
283
        mov.b #0x00,  &P6OUT
284
        mov.b #0x00,  &P6DIR
285
        mov.b #0x00,  &P6SEL
286
 
287
        mov   #0x0006, r15
288
 
289
 
290
        /* -------------- PORT 1: TEST I/O FUNCTIONALITY --------------- */
291
 
292
        mov     #0x0200, r15        ;# Test Input path
293 79 olivier.gi
        nop
294 2 olivier.gi
p1_din_loop:
295
        mov.b &P1IN,  0(r15)
296
        inc      r15
297
        cmp     #0x0208, r15
298
        jne     p1_din_loop
299
 
300
 
301
        mov.b #0x01,   &P1OUT       ; Test Output path
302
        mov   #0x1100, r15
303
p1_dout_loop:
304
        rla.b &P1OUT
305
        inc      r15
306
        cmp     #0x1107, r15
307
        jne     p1_dout_loop
308
 
309
 
310
        mov.b #0x01,   &P1DIR       ; Test Direction register
311
        mov   #0x1200, r15
312
p1_dir_loop:
313
        rla.b &P1DIR
314
        inc      r15
315
        cmp     #0x1207, r15
316
        jne     p1_dir_loop
317
 
318
 
319
        mov.b #0x01,   &P1SEL       ; Test Function Select register
320
        mov   #0x1300, r15
321
p1_sel_loop:
322
        rla.b &P1SEL
323
        inc      r15
324
        cmp     #0x1307, r15
325
        jne     p1_sel_loop
326
 
327
 
328
        mov.b #0x00,  &P1OUT        ; Re-Initialize
329
        mov.b #0x00,  &P1DIR
330
        mov.b #0x00,  &P1SEL
331
 
332
 
333
        /* -------------- PORT 2: TEST I/O FUNCTIONALITY --------------- */
334
 
335
        mov     #0x0210, r15        ;# Test Input path
336 79 olivier.gi
        nop
337 2 olivier.gi
p2_din_loop:
338
        mov.b &P2IN,  0(r15)
339
        inc      r15
340
        cmp     #0x0218, r15
341
        jne     p2_din_loop
342
 
343
 
344
        mov.b #0x01,   &P2OUT       ; Test Output path
345
        mov   #0x2100, r15
346
p2_dout_loop:
347
        rla.b &P2OUT
348
        inc      r15
349
        cmp     #0x2107, r15
350
        jne     p2_dout_loop
351
 
352
 
353
        mov.b #0x01,   &P2DIR       ; Test Direction register
354
        mov   #0x2200, r15
355
p2_dir_loop:
356
        rla.b &P2DIR
357
        inc      r15
358
        cmp     #0x2207, r15
359
        jne     p2_dir_loop
360
 
361
 
362
        mov.b #0x01,   &P2SEL       ; Test Function Select register
363
        mov   #0x2300, r15
364
p2_sel_loop:
365
        rla.b &P2SEL
366
        inc      r15
367
        cmp     #0x2307, r15
368
        jne     p2_sel_loop
369
 
370
 
371
        mov.b #0x00,  &P2OUT        ; Re-Initialize
372
        mov.b #0x00,  &P2DIR
373
        mov.b #0x00,  &P2SEL
374
 
375
 
376
        /* -------------- PORT 3: TEST I/O FUNCTIONALITY --------------- */
377
 
378
        mov     #0x0220, r15        ;# Test Input path
379 79 olivier.gi
        nop
380 2 olivier.gi
p3_din_loop:
381
        mov.b &P3IN,  0(r15)
382
        inc      r15
383
        cmp     #0x0228, r15
384
        jne     p3_din_loop
385
 
386
 
387
        mov.b #0x01,   &P3OUT       ; Test Output path
388
        mov   #0x3100, r15
389
p3_dout_loop:
390
        rla.b &P3OUT
391
        inc      r15
392
        cmp     #0x3107, r15
393
        jne     p3_dout_loop
394
 
395
 
396
        mov.b #0x01,   &P3DIR       ; Test Direction register
397
        mov   #0x3200, r15
398
p3_dir_loop:
399
        rla.b &P3DIR
400
        inc      r15
401
        cmp     #0x3207, r15
402
        jne     p3_dir_loop
403
 
404
 
405
        mov.b #0x01,   &P3SEL       ; Test Function Select register
406
        mov   #0x3300, r15
407
p3_sel_loop:
408
        rla.b &P3SEL
409
        inc      r15
410
        cmp     #0x3307, r15
411
        jne     p3_sel_loop
412
 
413
 
414
        mov.b #0x00,  &P3OUT        ; Re-Initialize
415
        mov.b #0x00,  &P3DIR
416
        mov.b #0x00,  &P3SEL
417
 
418
 
419
        /* -------------- PORT 4: TEST I/O FUNCTIONALITY --------------- */
420
 
421
        mov     #0x0230, r15        ;# Test Input path
422 79 olivier.gi
        nop
423 2 olivier.gi
p4_din_loop:
424
        mov.b &P4IN,  0(r15)
425
        inc      r15
426
        cmp     #0x0238, r15
427
        jne     p4_din_loop
428
 
429
 
430
        mov.b #0x01,   &P4OUT       ; Test Output path
431
        mov   #0x4100, r15
432
p4_dout_loop:
433
        rla.b &P4OUT
434
        inc      r15
435
        cmp     #0x4107, r15
436
        jne     p4_dout_loop
437
 
438
 
439
        mov.b #0x01,   &P4DIR       ; Test Direction register
440
        mov   #0x4200, r15
441
p4_dir_loop:
442
        rla.b &P4DIR
443
        inc      r15
444
        cmp     #0x4207, r15
445
        jne     p4_dir_loop
446
 
447
 
448
        mov.b #0x01,   &P4SEL       ; Test Function Select register
449
        mov   #0x4300, r15
450
p4_sel_loop:
451
        rla.b &P4SEL
452
        inc      r15
453
        cmp     #0x4307, r15
454
        jne     p4_sel_loop
455
 
456
 
457
        mov.b #0x00,  &P4OUT        ; Re-Initialize
458
        mov.b #0x00,  &P4DIR
459
        mov.b #0x00,  &P4SEL
460
 
461
 
462
        /* -------------- PORT 5: TEST I/O FUNCTIONALITY --------------- */
463
 
464
        mov     #0x0240, r15        ;# Test Input path
465 79 olivier.gi
        nop
466 2 olivier.gi
p5_din_loop:
467
        mov.b &P5IN,  0(r15)
468
        inc      r15
469
        cmp     #0x0248, r15
470
        jne     p5_din_loop
471
 
472
 
473
        mov.b #0x01,   &P5OUT       ; Test Output path
474
        mov   #0x5100, r15
475
p5_dout_loop:
476
        rla.b &P5OUT
477
        inc      r15
478
        cmp     #0x5107, r15
479
        jne     p5_dout_loop
480
 
481
 
482
        mov.b #0x01,   &P5DIR       ; Test Direction register
483
        mov   #0x5200, r15
484
p5_dir_loop:
485
        rla.b &P5DIR
486
        inc      r15
487
        cmp     #0x5207, r15
488
        jne     p5_dir_loop
489
 
490
 
491
        mov.b #0x01,   &P5SEL       ; Test Function Select register
492
        mov   #0x5300, r15
493
p5_sel_loop:
494
        rla.b &P5SEL
495
        inc      r15
496
        cmp     #0x5307, r15
497
        jne     p5_sel_loop
498
 
499
 
500
        mov.b #0x00,  &P5OUT        ; Re-Initialize
501
        mov.b #0x00,  &P5DIR
502
        mov.b #0x00,  &P5SEL
503
 
504
 
505
        /* -------------- PORT 6: TEST I/O FUNCTIONALITY --------------- */
506
 
507
        mov     #0x0250, r15        ;# Test Input path
508 79 olivier.gi
        nop
509 2 olivier.gi
p6_din_loop:
510
        mov.b &P6IN,  0(r15)
511
        inc      r15
512
        cmp     #0x0258, r15
513
        jne     p6_din_loop
514
 
515
 
516
        mov.b #0x01,   &P6OUT       ; Test Output path
517
        mov   #0x6100, r15
518
p6_dout_loop:
519
        rla.b &P6OUT
520
        inc      r15
521
        cmp     #0x6107, r15
522
        jne     p6_dout_loop
523
 
524
 
525
        mov.b #0x01,   &P6DIR       ; Test Direction register
526
        mov   #0x6200, r15
527
p6_dir_loop:
528
        rla.b &P6DIR
529
        inc      r15
530
        cmp     #0x6207, r15
531
        jne     p6_dir_loop
532
 
533
 
534
        mov.b #0x01,   &P6SEL       ; Test Function Select register
535
        mov   #0x6300, r15
536
p6_sel_loop:
537
        rla.b &P6SEL
538
        inc      r15
539
        cmp     #0x6307, r15
540
        jne     p6_sel_loop
541
 
542
 
543
        mov.b #0x00,  &P6OUT        ; Re-Initialize
544
        mov.b #0x00,  &P6DIR
545
        mov.b #0x00,  &P6SEL
546
 
547
 
548
 
549
        /* ----------------------         END OF TEST        --------------- */
550
end_of_test:
551
        nop
552
        br #0xffff
553
 
554
 
555
        /* ----------------------         INTERRUPT VECTORS  --------------- */
556
 
557
.section .vectors, "a"
558
.word end_of_test  ; Interrupt  0 (lowest priority)    
559
.word end_of_test  ; Interrupt  1                      
560
.word end_of_test  ; Interrupt  2                      
561
.word end_of_test  ; Interrupt  3                      
562
.word end_of_test  ; Interrupt  4                      
563
.word end_of_test  ; Interrupt  5                      
564
.word end_of_test  ; Interrupt  6                      
565
.word end_of_test  ; Interrupt  7                      
566
.word end_of_test  ; Interrupt  8                      
567
.word end_of_test  ; Interrupt  9                      
568
.word end_of_test  ; Interrupt 10                      Watchdog timer
569
.word end_of_test  ; Interrupt 11                      
570
.word end_of_test  ; Interrupt 12                      
571
.word end_of_test  ; Interrupt 13                      
572
.word end_of_test  ; Interrupt 14                      NMI
573
.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.