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

Subversion Repositories 8051

[/] [8051/] [trunk/] [asm/] [timer_test.asm] - Blame information for rev 185

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

Line No. Rev Author Line
1 131 simont
; r0: timer 0 owerflov counter
2
; r1: timer 1 owerflov counter
3
; r2: error code
4
; r3: timer high expected value
5
; r4: timer low expected value
6
; r5: owerflov counter expected value
7
 
8
        ajmp start;
9
 
10
        org 03h         ;external interrupt 0
11
        reti;
12
 
13
        org 0bh         ;t/c 0 interrupt
14
        inc r0;
15 155 simont
        nop;
16
        nop;
17
        nop;
18
        nop;
19 131 simont
        reti;
20
 
21
        org 13h         ;external interrupt 1
22
        reti;
23
 
24
        org 1bh         ;t/c 1 interrupt
25
        inc r1;
26 155 simont
        nop;
27
        nop;
28
        nop;
29
        nop;
30 131 simont
        reti;
31
 
32
        org 23h         ;serial interface interrupt
33
        reti;
34
 
35
 
36
test0:
37
        mov a, th0      ;
38
        subb a, r3      ;
39
        jnz error       ;
40
        inc r2          ;
41
        mov a,tl0       ;
42
        subb a, r4      ;
43
        jnz error       ;
44
        inc r2          ;
45
        mov a, r0       ;
46
        subb a, r5      ;
47
        jnz error       ;
48
        ret;
49
 
50
test1:
51
        mov a, th1      ;
52
        subb a, r3      ;
53
        jnz error       ;
54
        inc r2          ;
55
        mov a,tl1       ;
56
        subb a, r4      ;
57
        jnz error       ;
58
        inc r2          ;
59
        mov a, r1       ;
60
        subb a, r5      ;
61
        jnz error       ;
62
        ret;
63
 
64
 
65
error:
66
        mov p0, r2;
67
        nop;
68
        ajmp error;
69
 
70
wait:
71
        dec a           ; 1
72
        nop             ; 1
73
        nop             ; 1
74
        nop             ; 1
75
        nop             ; 1
76
        nop             ; 1
77
        nop             ; 1
78
        nop             ; 1
79 155 simont
        jnz wait        ; 4
80
        ret             ; 4
81 131 simont
 
82
 
83
start:
84
        clr a;
85
        mov r0, a;
86
        mov r1, a;
87
        mov ie, #08ah   ;enable interrupts
88
        clr c;
89
 
90
;
91
; timer 0 test
92
;
93
; mode 0
94
;
95
        mov tmod, #000h ;t/c 0 and t/c 1 in timer mode 0
96
        mov th0, #000h  ;load timer 0
97
        mov tl0, #000h  ;
98
        mov tcon, #010h ;start timer 0;
99
 
100
        mov a, #03h     ; 1
101 155 simont
        acall wait      ; 3
102 131 simont
        nop;
103
        nop;
104
        nop;
105
 
106
 
107
        clr tcon.4      ;stop timer 0
108
        mov r2, #010h   ;
109
        mov r3, #000h   ;
110
        mov r4, #004h   ;
111
        mov r5, #000h   ;
112
        acall test0     ;
113
 
114
        mov tl0, #01ch  ; load timer 0
115
        setb tcon.4     ;start timer 0;
116
 
117
        mov a, #04h     ; 1
118
        acall wait      ; 2
119
        nop;
120
        nop;
121
        nop;
122
        clr tcon.4      ;stop timer 0;
123
        mov r2, #020h   ;
124
        mov r3, #001h   ;
125
        mov r4, #001h   ;
126
        mov r5, #000h   ;
127
        acall test0     ;
128
 
129
        mov tl0, #01ch  ;
130
        mov th0, #0ffh  ;
131
        setb tcon.4     ;start timer 0
132
        mov a, #05h     ;
133
        acall wait      ;
134
        nop;
135
        nop;
136
        nop;
137
        clr tcon.4      ;stop timer 0
138
        mov r2, #030h   ;
139
        mov r3, #000h   ;
140 155 simont
        mov r4, #003h   ;
141 131 simont
        mov r5, #001h   ;
142
        acall test0     ;
143
;
144
; mode 1
145
;
146
        mov tmod, #001h ; t/c 0 in mode 1
147
        mov th0, #000h  ;load timer 0
148
        mov tl0, #000h  ;
149
        setb tcon.4     ;start timer 0;
150
        mov a, #03h     ;
151
        acall wait      ;
152
        nop;
153
        nop;
154
        nop;
155
        clr tcon.4      ;stop timer 0
156
        mov r2, #040h   ;
157
        mov r3, #000h   ;
158
        mov r4, #004h   ;
159
        mov r5, #001h   ;
160
        acall test0     ;
161
 
162
        mov tl0, #0fch  ; load timer 0
163
        setb tcon.4     ;start timer 0;
164
        mov a, #04h     ;
165
        acall wait      ;
166
        nop;
167
        nop;
168
        nop;
169
        clr tcon.4      ;stop timer 0;
170
        mov r2, #050h   ;
171
        mov r3, #001h   ;
172
        mov r4, #001h   ;
173
        mov r5, #001h   ;
174
        acall test0     ;
175
 
176
        mov tl0, #0fch  ;
177
        mov th0, #0ffh  ;
178
        setb tcon.4     ;start timer 0
179
        mov a, #05h     ;
180
        acall wait      ;
181
        nop;
182
        nop;
183
        nop;
184
        clr tcon.4      ;stop timer 0
185
        mov r2, #060h   ;
186
        mov r3, #000h   ;
187 155 simont
        mov r4, #003h   ;
188 131 simont
        mov r5, #002h   ;
189
        acall test0     ;
190
;
191
; mode 2
192
;
193
        mov tmod, #002h ; t/c 0 in mode 2
194
        mov th0, #000h  ;load timer 0
195
        mov tl0, #005h  ;
196
        setb tcon.4     ;start timer 0;
197
        mov a, #03h     ;
198
        acall wait      ;
199
        nop;
200
        nop;
201
        nop;
202
        clr tcon.4      ;stop timer 0
203
        mov r2, #070h   ;
204
        mov r3, #000h   ;
205
        mov r4, #009h   ;
206
        mov r5, #002h   ;
207
        acall test0     ;
208
 
209
        mov tl0, #0fch  ; load timer 0
210
        mov th0, #050h  ;
211
        setb tcon.4     ;start timer 0;
212
        mov a, #05h     ;
213
        acall wait      ;
214
        nop;
215
        nop;
216
        nop;
217
        clr tcon.4      ;stop timer 0;
218
        mov r2, #080h   ;
219
        mov r3, #050h   ;
220
        mov r4, #053h   ;
221
        mov r5, #003h   ;
222
        acall test0     ;
223
;
224
; mode 3
225
;
226
        mov tmod, #003h ; t/c 0 in mode 3
227
        mov th0, #000h  ;load timer 0
228
        mov tl0, #000h  ;
229
        setb tcon.4     ;start timer 0;
230
        mov a, #03h     ;
231
        acall wait      ;
232
        nop;
233
        nop;
234
        nop;
235
        clr tcon.4      ;stop timer 0
236
        mov r2, #090h   ;
237
        mov r3, #000h   ;
238
        mov r4, #004h   ;
239
        mov r5, #003h   ;
240
        acall test0     ;
241
 
242
        mov tl0, #0fch  ; load timer 0
243
        mov th0, #000h  ;
244
        setb tcon.4     ;start timer 0
245
        mov a, #05h     ;
246
        acall wait      ;
247
        nop;
248
        nop;
249
        nop;
250
        clr tcon.4      ;stop timer 0
251
        mov r2, #0a0h   ;
252
        mov r3, #000h   ;
253
        mov r4, #003h   ;
254
        mov r5, #004h   ;
255
        acall test0     ;
256
 
257
        mov tl0, #000h  ; load timer 0
258
        mov th0, #000h  ;
259
        setb tcon.6     ; start timer 1
260
        mov a, #03h     ;
261
        acall wait      ;
262
        nop;
263
        nop;
264
        nop;
265
        clr tcon.6      ; stop timer 1
266
        mov r2, #0b0h   ;
267
        mov r3, #004h   ;
268
        mov r4, #000h   ;
269
        mov r5, #004h   ;
270
        acall test0     ;
271
 
272
        mov tl0, #000h  ; load timer 0
273
        mov th0, #0fch  ;
274
        setb tcon.6     ;start timer 1
275
        mov a, #05h     ;
276
        acall wait      ;
277
        nop;
278
        nop;
279
        nop;
280
        clr tcon.6      ;stop timer 1
281
        mov r2, #0c0h   ;
282 155 simont
        mov r3, #003h   ;
283 131 simont
        mov r4, #000h   ;
284
        mov r5, #001h   ;
285
        mov r0, 01h     ;
286
        acall test0     ;
287
 
288
        mov p0, #001h   ; test timer 0 done!
289
        mov r1, #000h   ;
290
 
291
;
292
; timer 1 test
293
;
294
; mode 0
295
;
296
        mov tmod, #000h ;t/c 0 and t/c 1 in timer mode 0
297
        mov th1, #000h  ;load timer 1
298
        mov tl1, #000h  ;
299
        mov tcon, #040h ;start timer 1;
300
        mov a, #03h     ;
301
        acall wait      ;
302
        nop;
303
        nop;
304
        nop;
305
        clr tcon.6      ;stop timer 1
306
        mov r2, #018h   ;
307
        mov r3, #000h   ;
308
        mov r4, #004h   ;
309
        mov r5, #000h   ;
310
        acall test1     ;
311
 
312
        mov tl1, #01ch  ; load timer 1
313
        setb tcon.6     ;start timer 1
314
        mov a, #04h     ;
315
        acall wait      ;
316
        nop;
317
        nop;
318
        nop;
319
        clr tcon.6      ;stop timer 1
320
        mov r2, #028h   ;
321
        mov r3, #001h   ;
322
        mov r4, #001h   ;
323
        mov r5, #000h   ;
324
        acall test1     ;
325
 
326
        mov tl1, #01ch  ;
327
        mov th1, #0ffh  ;
328
        setb tcon.6     ;start timer 1
329
        mov a, #05h     ;
330
        acall wait      ;
331
        nop;
332
        nop;
333
        nop;
334
        clr tcon.6      ;stop timer 1
335
        mov r2, #038h   ;
336
        mov r3, #000h   ;
337
        mov r4, #003h   ;
338
        mov r5, #001h   ;
339
        acall test1     ;
340
;
341
; mode 1
342
;
343
        mov tmod, #010h ; t/c 1 in mode 1
344
        mov th1, #000h  ;load timer 1
345
        mov tl1, #000h  ;
346
        setb tcon.6     ;start timer 1
347
        mov a, #03h     ;
348
        acall wait      ;
349
        nop;
350
        nop;
351
        nop;
352
        clr tcon.6      ;stop timer 1
353
        mov r2, #048h   ;
354
        mov r3, #000h   ;
355
        mov r4, #004h   ;
356
        mov r5, #001h   ;
357
        acall test1     ;
358
 
359
        mov tl1, #0fch  ; load timer 1
360
        setb tcon.6     ; start timer 1
361
        mov a, #04h     ;
362
        acall wait      ;
363
        nop;
364
        nop;
365
        nop;
366
        clr tcon.6      ;stop timer 1
367
        mov r2, #058h   ;
368
        mov r3, #001h   ;
369
        mov r4, #001h   ;
370
        mov r5, #001h   ;
371
        acall test1     ;
372
 
373
        mov tl1, #0fch  ;
374
        mov th1, #0ffh  ;
375
        setb tcon.6     ;start timer 1
376
        mov a, #05h     ;
377
        acall wait      ;
378
        nop;
379
        nop;
380
        nop;
381
        clr tcon.6      ;stop timer 1
382
        mov r2, #068h   ;
383
        mov r3, #000h   ;
384 155 simont
        mov r4, #004h   ;
385 131 simont
        mov r5, #002h   ;
386
        acall test1     ;
387
;
388
; mode 2
389
;
390
        mov tmod, #020h ; t/c 1 in mode 2
391
        mov th1, #000h  ;load timer 1
392
        mov tl1, #005h  ;
393
        setb tcon.6     ;start timer 1
394
        mov a, #03h     ;
395
        acall wait      ;
396
        nop;
397
        nop;
398
        clr tcon.6      ;stop timer 1
399
        mov r2, #078h   ;
400
        mov r3, #000h   ;
401
        mov r4, #009h   ;
402
        mov r5, #002h   ;
403
        acall test1     ;
404
 
405
        mov tl1, #0fch  ; load timer 1
406
        mov th1, #050h  ;
407
        setb tcon.6     ;start timer 1
408
        mov a, #04h     ;
409
        acall wait      ;
410
        nop;
411
        nop;
412
        nop;
413
        clr tcon.6      ;stop timer 1
414
        mov r2, #088h   ;
415
        mov r3, #050h   ;
416 155 simont
        mov r4, #052h   ;
417 131 simont
        mov r5, #003h   ;
418
        acall test1     ;
419
;
420
; mode 3
421
;
422
        mov tmod, #030h ; t/c 1 in mode 3
423
        mov th1, #000h  ;load timer 1
424
        mov tl1, #000h  ;
425
        setb tcon.6     ;start timer 1
426
        mov a, #03h     ;
427
        acall wait      ;
428
        nop;
429
        nop;
430
        nop;
431
        clr tcon.6      ;stop timer 1
432
        mov r2, #098h   ;
433
        mov r3, #000h   ;
434
        mov r4, #000h   ;
435
        mov r5, #003h   ;
436
        acall test1     ;
437
 
438
        mov tl1, #0fch  ; load timer 1
439
        mov th1, #0ffh  ;
440
        setb tcon.6     ;start timer 1
441
        mov a, #05h     ;
442
        acall wait      ;
443
        nop;
444
        nop;
445
        nop;
446
        clr tcon.6      ;stop timer 1
447
        mov r2, #0a8h   ;
448
        mov r3, #0ffh   ;
449
        mov r4, #0fch   ;
450
        mov r5, #003h   ;
451
        acall test1     ;
452
 
453
        mov p0, #002h   ; test timer 1 done!
454
 
455
end
456
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.