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

Subversion Repositories 8051

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

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

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

powered by: WebSVN 2.1.0

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