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

Subversion Repositories 8051

[/] [8051/] [tags/] [rel_2/] [asm/] [timer2_test.asm] - Blame information for rev 79

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

Line No. Rev Author Line
1 79 simont
; b:  error code
2
; r3: timer high expected value
3
; r4: timer low expected value
4
 
5
 
6
t2con   EQU 0c8h;
7
t2mod   EQU 0c9h;
8
rcap2l  EQU 0cah;
9
rcap2h  EQU 0cbh;
10
tl2     EQU 0cch;
11
th2     EQU 0cdh;
12
 
13
tr2     EQU 0cah;
14
exen2   EQU 0cbh;
15
exf2    EQU 0ceh;
16
tf2     EQU 0cfh;
17
 
18
        ajmp start;
19
 
20
        org 03h ;       external interrupt 0
21
        reti;
22
 
23
        org 0bh ;       t/c 0 interrupt
24
        reti;
25
 
26
        org 13h ;       external interrupt 1
27
        reti;
28
 
29
        org 1bh ;       t/c 1 interrupt
30
        reti;
31
 
32
        org 23h ;       serial interface interrupt
33
        reti;
34
 
35
        org 2bh;        t/c 2 interrupt
36
        reti;
37
 
38
 
39
test2:
40
        mov a, th2      ;
41
        subb a, r3      ;
42
        jnz error       ;
43
 
44
        mov a,tl2       ;
45
        subb a, r4      ;
46
        jnz error       ;
47
 
48
        ret;
49
 
50
 
51
error:
52
        mov p1, b;
53
        nop;
54
        ajmp error;
55
 
56
 
57
start:
58
        clr a;
59
        mov r0, a;
60
        mov r1, a;
61
        mov ie, #00h    ;disable interrupts
62
        clr c;
63
 
64
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
65
;
66
; timer 2 test
67
;
68
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
69
;
70
; capture mode
71
;
72
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
73
 
74
        mov tcon, #000h ; disable t/c 0,1
75
        mov t2con, #01h; timer 2 capture mode,
76
        mov th2, #000h  ;load timer 2
77
        mov tl2, #000h  ;
78
        setb tr2        ;start timer 2;
79
        nop;
80
        nop;
81
        nop;
82
        clr tr2         ;stop timer 2
83
        mov b, #00h     ; error 0
84
        mov r3, #000h   ;
85
        mov r4, #004h   ;
86
        acall test2     ;
87
 
88
        mov tl2, #0fch  ; load timer 2
89
        setb tr2        ; start timer 2;
90
        nop;
91
        nop;
92
        nop;
93
        nop;
94
        clr tr2         ; stop timer 2
95
        mov b, #01h     ; error 1
96
        mov r3, #001h   ;
97
        mov r4, #001h   ;
98
        acall test2     ;
99
 
100
        mov tl2, #0fch  ;
101
        mov th2, #0ffh  ;
102
        setb tr2        ;start timer 2
103
        nop;
104
        nop;
105
        nop;
106
        nop;
107
        nop;
108
        clr tr2         ;stop timer 0
109
        mov b, #02h     ; error 2
110
        mov r3, #000h   ;
111
        mov r4, #002h   ;
112
        acall test2     ;
113
        mov b, #03h     ; error 3
114
        jnb tf2, error  ;
115
        clr tf2         ;
116
 
117
        mov p0, #01h;
118
;
119
; test exen2
120
;
121
        mov rcap2l, #43h
122
        mov rcap2h, #21h
123
        mov th2, #23h   ;
124
        mov tl2, #45h   ;
125
        clr p3.2        ;
126
        setb p3.2       ;
127
        mov a, #10h     ;
128
loop1:  nop             ;
129
        dec a           ;
130
        jnz loop1       ;
131
        mov a, rcap2l   ;
132
        mov psw, #00h   ;
133
        mov b, #04h     ;error 4
134
        subb a, #43h    ;
135
        jnz error0      ;
136
        mov a, rcap2h   ;
137
        subb a, #21h    ;
138
        jnz error0      ;
139
 
140
        mov b, #05h     ;error 5
141
        jb exf2, error0 ;
142
        clr exf2        ;
143
 
144
        setb exen2      ;
145
        clr p3.2        ;
146
        setb p3.2       ;
147
        mov a, #10h     ;
148
loop2:  nop             ;
149
        dec a           ;
150
        jnz loop2       ;
151
        mov a, rcap2l   ;
152
        mov psw, #00h   ;
153
        mov b, #06h     ;error 6
154
        subb a, #45h    ;
155
        jnz error0      ;
156
        mov a, rcap2h   ;
157
        subb a, #23h    ;
158
        jnz error0      ;
159
 
160
        mov b, #07h     ;error 7
161
        jnb exf2, error0;
162
        clr exf2        ;
163
 
164
        mov p0, #02h;
165
 
166
        ajmp arm;
167
 
168
error0:
169
        ljmp error;
170
 
171
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
172
;
173
; auto reload mode, up counter
174
;
175
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
176
arm:
177
        mov t2con, #00h ; t/c 2 in auto reload mode
178
        mov th2, #000h  ;load timer 2
179
        mov tl2, #000h  ;
180
        mov rcap2l, #11h;
181
        mov rcap2h, #22h;
182
        setb tr2        ;start timer 2;
183
        nop;
184
        nop;
185
        nop;
186
        clr tr2         ;stop timer 2
187
        mov b, #08h     ; error 8
188
        mov r3, #000h   ;
189
        mov r4, #004h   ;
190
        acall test2     ;
191
 
192
        mov tl2, #0fch  ; load timer 2
193
        setb tr2        ; start timer 2
194
        nop;
195
        nop;
196
        nop;
197
        nop;
198
        clr tr2         ; stop timer 2
199
        mov b, #09h     ; error 9
200
        mov r3, #001h   ;
201
        mov r4, #001h   ;
202
        acall test2     ;
203
 
204
        mov b, #0ah     ; error a
205
        jb  tf2, error0 ;
206
        clr tf2 ;
207
 
208
 
209
        mov tl2, #0fch  ;
210
        mov th2, #0ffh  ;
211
        setb tr2        ;start timer 2
212
        nop;
213
        nop;
214
        nop;
215
        nop;
216
        nop;
217
        clr tr2         ;stop timer 0
218
        mov b, #0bh     ; error b
219
        mov r3, #022h   ;
220
        mov r4, #013h   ;
221
        acall test2     ;
222
 
223
        mov b, #0ch     ; error c
224
        jnb tf2, error0 ;
225
        clr tf2 ;
226
 
227
 
228
        mov a, rcap2l   ;
229
        mov psw, #00h   ;
230
        mov b, #0f0h    ;error f0
231
        subb a, #11h    ;
232
        jnz error1      ;
233
        mov a, rcap2h   ;
234
        subb a, #22h    ;
235
        jnz error0      ;
236
 
237
        mov p0, #03h;
238
 
239
 
240
;
241
; test exen2
242
;
243
        mov rcap2l, #12h
244
        mov rcap2h, #34h
245
        mov tl2, #56h   ;
246
        mov th2, #78h   ;
247
        clr p3.2        ;
248
        setb p3.2       ;
249
        mov a, #10h     ;
250
loop3:  nop             ;
251
        dec a           ;
252
        jnz loop3       ;
253
 
254
        mov b, #0dh     ; error d
255
        mov r3, #078h   ;
256
        mov r4, #056h   ;
257
        acall test2     ;
258
 
259
        mov b, #0eh     ; error e
260
        jb exf2, error1 ;
261
        clr exf2        ;
262
 
263
        setb exen2      ;
264
        clr p3.2        ;
265
        setb p3.2       ;
266
        mov a, #10h     ;
267
loop4:  nop             ;
268
        dec a           ;
269
        jnz loop4       ;
270
 
271
        mov b, #0fh     ; error f
272
        mov r3, #034h   ;
273
        mov r4, #012h   ;
274
        acall test2     ;
275
 
276
        mov b, #10h     ;error 10
277
        jnb exf2, error1;
278
        clr exf2        ;
279
 
280
        mov a, rcap2l   ;
281
        mov psw, #00h   ;
282
        mov b, #0f1h    ;error f1
283
        subb a, #12h    ;
284
        jnz error1      ;
285
        mov a, rcap2h   ;
286
        subb a, #34h    ;
287
        jnz error1      ;
288
 
289
        mov p0, #04h    ;
290
 
291
        ajmp upc;
292
 
293
 
294
error1:
295
        ljmp error;
296
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
297
;
298
; auto reload mode, up/down counter
299
;
300
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
301
;
302
; up counter
303
;
304
upc:
305
        mov t2con, #00h ; t/c 2 in auto reload mode
306
        mov t2mod, #01h ;
307
        setb p3.2       ;
308
        mov th2, #000h  ;load timer 2
309
        mov tl2, #000h  ;
310
        mov rcap2l, #33h;
311
        mov rcap2h, #44h;
312
        setb tr2        ;start timer 2;
313
        nop;
314
        nop;
315
        nop;
316
        clr tr2         ;stop timer 2
317
        mov b, #11h     ; error 11
318
        mov r3, #000h   ;
319
        mov r4, #004h   ;
320
        acall test2     ;
321
 
322
        mov tl2, #0fch  ; load timer 2
323
        setb tr2        ; start timer 2
324
        nop;
325
        nop;
326
        nop;
327
        nop;
328
        clr tr2         ; stop timer 2
329
        mov b, #12h     ; error 12
330
        mov r3, #001h   ;
331
        mov r4, #001h   ;
332
        acall test2     ;
333
 
334
        mov b, #13h     ; error 13
335
        jb  tf2, error1 ;
336
        clr tf2 ;
337
 
338
        mov b, #14h     ; error 14
339
        jb  exf2, error1;
340
 
341
        mov tl2, #0fch  ;
342
        mov th2, #0ffh  ;
343
        setb tr2        ;start timer 2
344
        nop;
345
        nop;
346
        nop;
347
        nop;
348
        nop;
349
        clr tr2         ;stop timer 2
350
        mov b, #15h     ; error 15
351
        mov r3, #044h   ;
352
        mov r4, #035h   ;
353
        acall test2     ;
354
 
355
        mov b, #16h     ; error 16
356
        jnb tf2, error1 ;
357
        clr tf2 ;
358
 
359
        mov b, #17h     ; error 17
360
        jnb exf2, error1;
361
 
362
 
363
        mov tl2, #0fch  ;
364
        mov th2, #0ffh  ;
365
        setb tr2        ;start timer 2
366
        nop;
367
        nop;
368
        nop;
369
        nop;
370
        nop;
371
        clr tr2         ;stop timer 2
372
 
373
        mov b, #18h     ; error 18
374
        jb exf2, error15;
375
        clr exf2        ;
376
        clr tf2 ;
377
 
378
        mov a, rcap2l   ;
379
        mov psw, #00h   ;
380
        mov b, #0f2h    ;error f2
381
        subb a, #33h    ;
382
        jnz error15     ;
383
        mov a, rcap2h   ;
384
        subb a, #44h    ;
385
        jnz error15     ;
386
 
387
        mov p0, #05h    ;
388
 
389
        ajmp down;
390
 
391
error15:
392
        ljmp error;
393
 
394
;
395
; down counter
396
;
397
down:
398
        mov t2con, #00h ; t/c 2 in auto reload mode
399
        mov t2mod, #01h ;
400
        clr p3.2        ;
401
        mov th2, #0e2h  ;load timer 2
402
        mov tl2, #048h  ;
403
        mov rcap2l, #11h;
404
        mov rcap2h, #22h;
405
        setb tr2        ;start timer 2;
406
        nop;
407
        nop;
408
        nop;
409
        clr tr2         ;stop timer 2
410
        mov b, #19h     ; error 19
411
        mov r3, #0e2h   ;
412
        mov r4, #044h   ;
413
        acall test2     ;
414
 
415
        mov tl2, #01h   ; load timer 2
416
        setb tr2        ; start timer 2
417
        nop;
418
        nop;
419
        nop;
420
        nop;
421
        clr tr2         ; stop timer 2
422
        mov b, #1ah     ; error 1a
423
        mov r3, #0e1h   ;
424
        mov r4, #0fch   ;
425
        acall test2     ;
426
 
427
        mov b, #1bh     ; error 1b
428
        jb  tf2, error2 ;
429
        clr tf2 ;
430
 
431
        mov b, #1ch     ; error 1c
432
        jb  exf2, error2;
433
 
434
        mov tl2, #012h  ;
435
        mov th2, #022h  ;
436
        setb tr2        ;start timer 2
437
        nop;
438
        nop;
439
        nop;
440
        nop;
441
        nop;
442
        clr tr2         ;stop timer 2
443
        mov b, #1dh     ; error 1d
444
        mov r3, #0ffh   ;
445
        mov r4, #0fbh   ;
446
        acall test2     ;
447
 
448
        mov b, #1eh     ; error 1e
449
        jnb tf2, error2 ;
450
        clr tf2 ;
451
 
452
        mov b, #1fh     ; error 1f
453
        jnb exf2, error2;
454
 
455
 
456
        mov tl2, #012h  ;
457
        mov th2, #022h  ;
458
        setb tr2        ;start timer 2
459
        nop;
460
        nop;
461
        nop;
462
        nop;
463
        nop;
464
        clr tr2         ;stop timer 2
465
 
466
        mov b, #18h     ; error 18
467
        jb exf2, error2 ;
468
        clr exf2        ;
469
        clr tf2 ;
470
 
471
        mov a, rcap2l   ;
472
        mov psw, #00h   ;
473
        mov b, #04h     ;error f3
474
        subb a, #11h    ;
475
        jnz error2      ;
476
        mov a, rcap2h   ;
477
        subb a, #22h    ;
478
        jnz error2      ;
479
 
480
        mov p0, #06h    ;
481
 
482
        ajmp brate;
483
 
484
 
485
 
486
error2:
487
        ljmp error;
488
 
489
 
490
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
491
;
492
; baud rate generator
493
;
494
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
495
brate:
496
        mov t2con, #10h ; t/c 2 in baud rate generator mode
497
        mov th2, #000h  ;load timer 2
498
        mov tl2, #000h  ;
499
        mov rcap2l, #11h;
500
        mov rcap2h, #22h;
501
        setb tr2        ;start timer 2;
502
        nop;
503
        nop;
504
        nop;
505
        clr tr2         ;stop timer 2
506
        mov b, #20h     ; error 20
507
        mov r3, #000h   ;
508
        mov r4, #004h   ;
509
        acall test2     ;
510
 
511
        mov t2con, #20h ;
512
        mov tl2, #0fch  ; load timer 2
513
        setb tr2        ; start timer 2
514
        nop;
515
        nop;
516
        nop;
517
        nop;
518
        clr tr2         ; stop timer 2
519
        mov b, #021h    ; error 21
520
        mov r3, #001h   ;
521
        mov r4, #001h   ;
522
        acall test2     ;
523
 
524
        mov b, #22h     ; error 22
525
        jb  tf2, error2 ;
526
        clr tf2 ;
527
 
528
 
529
        mov tl2, #0fch  ;
530
        mov th2, #0ffh  ;
531
        setb tr2        ;start timer 2
532
        nop;
533
        nop;
534
        nop;
535
        nop;
536
        nop;
537
        clr tr2         ;stop timer 0
538
        mov b, #23h     ; error 23
539
        mov r3, #022h   ;
540
        mov r4, #013h   ;
541
        acall test2     ;
542
 
543
        mov b, #24h     ; error 24
544
        jb tf2, error2  ;
545
        clr tf2 ;
546
 
547
 
548
        mov a, rcap2l   ;
549
        mov psw, #00h   ;
550
        mov b, #0f4h    ;error f4
551
        subb a, #11h    ;
552
        jnz error2      ;
553
        mov a, rcap2h   ;
554
        subb a, #22h    ;
555
        jnz error2      ;
556
 
557
        mov p0, #07h;
558
 
559
 
560
;
561
; test exen2
562
;
563
        mov tl2, #56h   ;
564
        mov th2, #78h   ;
565
        setb p3.2       ;
566
        clr p3.2        ;
567
        setb p3.2       ;
568
        mov a, #10h     ;
569
loop5:  nop             ;
570
        dec a           ;
571
        jnz loop5       ;
572
 
573
        mov b, #25h     ; error 25
574
        mov r3, #078h   ;
575
        mov r4, #056h   ;
576
        acall test2     ;
577
 
578
        mov b, #0eh     ; error e
579
        jb exf2, error3 ;
580
        clr exf2        ;
581
 
582
        setb exen2      ;
583
        clr p3.2        ;
584
        setb p3.2       ;
585
        mov a, #10h     ;
586
loop6:  nop             ;
587
        dec a           ;
588
        jnz loop6       ;
589
 
590
        mov b, #26h     ; error 26
591
        mov r3, #078h   ;
592
        mov r4, #056h   ;
593
        acall test2     ;
594
 
595
        mov b, #27h     ;error 27
596
        jnb exf2, error3;
597
        clr exf2        ;
598
 
599
 
600
        mov p0, #08h    ;
601
        ajmp counter;
602
 
603
error3:
604
        ljmp error;
605
 
606
 
607
 
608
 
609
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
610
;
611
; counter 2 test
612
;
613
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
614
;
615
; capture mode
616
;
617
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
618
counter:
619
        mov tcon, #000h ; disable t/c 0,1
620
        mov t2con, #03h; timer 2 capture mode,
621
        mov th2, #000h  ;load timer 2
622
        mov tl2, #000h  ;
623
        setb tr2        ;start timer 2;
624
        cpl p3.5;
625
        cpl p3.5;
626
        cpl p3.5;
627
        cpl p3.5;
628
        cpl p3.5;
629
        cpl p3.5;
630
        cpl p3.5;
631
        cpl p3.5;
632
        clr tr2         ;stop timer 2
633
        mov b, #00h     ; error 0
634
        mov r3, #000h   ;
635
        mov r4, #004h   ;
636
        acall test2     ;
637
 
638
        mov tl2, #0fch  ; load timer 2
639
        setb tr2        ; start timer 2;
640
        cpl p3.5;
641
        cpl p3.5;
642
        cpl p3.5;
643
        cpl p3.5;
644
        cpl p3.5;
645
        cpl p3.5;
646
        cpl p3.5;
647
        cpl p3.5;
648
        cpl p3.5;
649
        cpl p3.5;
650
        clr tr2         ; stop timer 2
651
        mov b, #01h     ; error 1
652
        mov r3, #001h   ;
653
        mov r4, #001h   ;
654
        acall test2     ;
655
 
656
        mov tl2, #0fch  ;
657
        mov th2, #0ffh  ;
658
        setb tr2        ;start timer 2
659
        cpl p3.5;
660
        cpl p3.5;
661
        cpl p3.5;
662
        cpl p3.5;
663
        cpl p3.5;
664
        cpl p3.5;
665
        cpl p3.5;
666
        cpl p3.5;
667
        cpl p3.5;
668
        cpl p3.5;
669
        cpl p3.5;
670
        cpl p3.5;
671
        clr tr2         ;stop timer 0
672
        mov b, #02h     ; error 2
673
        mov r3, #000h   ;
674
        mov r4, #002h   ;
675
        acall test2     ;
676
        mov b, #03h     ; error 3
677
        jnb tf2, error4 ;
678
        clr tf2         ;
679
 
680
        mov p0, #09h;
681
;
682
; test exen2
683
;
684
        mov rcap2l, #43h
685
        mov rcap2h, #21h
686
        mov th2, #23h   ;
687
        mov tl2, #45h   ;
688
        clr p3.2        ;
689
        setb p3.2       ;
690
        mov a, #10h     ;
691
loop7:  nop             ;
692
        dec a           ;
693
        jnz loop7       ;
694
        mov a, rcap2l   ;
695
        mov psw, #00h   ;
696
        mov b, #04h     ;error 4
697
        subb a, #43h    ;
698
        jnz error4      ;
699
        mov a, rcap2h   ;
700
        subb a, #21h    ;
701
        jnz error4      ;
702
 
703
        mov b, #05h     ;error 5
704
        jb exf2, error4 ;
705
        clr exf2        ;
706
 
707
        setb exen2      ;
708
        clr p3.2        ;
709
        setb p3.2       ;
710
        mov a, #10h     ;
711
loop8:  nop             ;
712
        dec a           ;
713
        jnz loop8       ;
714
        mov a, rcap2l   ;
715
        mov psw, #00h   ;
716
        mov b, #06h     ;error 6
717
        subb a, #45h    ;
718
        jnz error4      ;
719
        mov a, rcap2h   ;
720
        subb a, #23h    ;
721
        jnz error4      ;
722
 
723
        mov b, #07h     ;error 7
724
        jnb exf2, error4;
725
        clr exf2        ;
726
 
727
        mov p0, #0ah;
728
 
729
        ajmp armc;
730
 
731
error4:
732
        ljmp error;
733
 
734
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
735
;
736
; auto reload mode, up counter
737
;
738
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
739
armc:
740
        mov t2con, #02h ; t/c 2 in auto reload mode
741
        mov th2, #000h  ;load timer 2
742
        mov tl2, #000h  ;
743
        mov rcap2l, #11h;
744
        mov rcap2h, #22h;
745
        setb tr2        ;start timer 2;
746
        cpl p3.5;
747
        cpl p3.5;
748
        cpl p3.5;
749
        cpl p3.5;
750
        cpl p3.5;
751
        cpl p3.5;
752
        cpl p3.5;
753
        cpl p3.5;
754
        clr tr2         ;stop timer 2
755
        mov b, #08h     ; error 8
756
        mov r3, #000h   ;
757
        mov r4, #004h   ;
758
        acall test2     ;
759
 
760
        mov tl2, #0fch  ; load timer 2
761
        setb tr2        ; start timer 2
762
        cpl p3.5;
763
        cpl p3.5;
764
        cpl p3.5;
765
        cpl p3.5;
766
        cpl p3.5;
767
        cpl p3.5;
768
        cpl p3.5;
769
        cpl p3.5;
770
        cpl p3.5;
771
        cpl p3.5;
772
        clr tr2         ; stop timer 2
773
        mov b, #09h     ; error 9
774
        mov r3, #001h   ;
775
        mov r4, #001h   ;
776
        acall test2     ;
777
 
778
        mov b, #0ah     ; error a
779
        jb  tf2, error4 ;
780
        clr tf2 ;
781
 
782
 
783
        mov tl2, #0fch  ;
784
        mov th2, #0ffh  ;
785
        setb tr2        ;start timer 2
786
        cpl p3.5;
787
        cpl p3.5;
788
        cpl p3.5;
789
        cpl p3.5;
790
        cpl p3.5;
791
        cpl p3.5;
792
        cpl p3.5;
793
        cpl p3.5;
794
        cpl p3.5;
795
        cpl p3.5;
796
        cpl p3.5;
797
        cpl p3.5;
798
        clr tr2         ;stop timer 0
799
        mov b, #0bh     ; error b
800
        mov r3, #022h   ;
801
        mov r4, #013h   ;
802
        acall test2     ;
803
 
804
        mov b, #0ch     ; error c
805
        jnb tf2, error5 ;
806
        clr tf2 ;
807
 
808
 
809
        mov a, rcap2l   ;
810
        mov psw, #00h   ;
811
        mov b, #0f0h    ;error f0
812
        subb a, #11h    ;
813
        jnz error5      ;
814
        mov a, rcap2h   ;
815
        subb a, #22h    ;
816
        jnz error5      ;
817
 
818
        mov p0, #0bh;
819
 
820
 
821
;
822
; test exen2
823
;
824
        mov rcap2l, #12h
825
        mov rcap2h, #34h
826
        mov tl2, #56h   ;
827
        mov th2, #78h   ;
828
        clr p3.2        ;
829
        setb p3.2       ;
830
        mov a, #10h     ;
831
loop9:  nop             ;
832
        dec a           ;
833
        jnz loop9       ;
834
 
835
        mov b, #0dh     ; error d
836
        mov r3, #078h   ;
837
        mov r4, #056h   ;
838
        acall test2     ;
839
 
840
        mov b, #0eh     ; error e
841
        jb exf2, error5 ;
842
        clr exf2        ;
843
 
844
        setb exen2      ;
845
        clr p3.2        ;
846
        setb p3.2       ;
847
        mov a, #10h     ;
848
loop10: nop             ;
849
        dec a           ;
850
        jnz loop10      ;
851
 
852
        mov b, #0fh     ; error f
853
        mov r3, #034h   ;
854
        mov r4, #012h   ;
855
        acall test2     ;
856
 
857
        mov b, #10h     ;error 10
858
        jnb exf2, error5;
859
        clr exf2        ;
860
 
861
        mov a, rcap2l   ;
862
        mov psw, #00h   ;
863
        mov b, #0f1h    ;error f1
864
        subb a, #12h    ;
865
        jnz error5      ;
866
        mov a, rcap2h   ;
867
        subb a, #34h    ;
868
        jnz error5      ;
869
 
870
        mov p0, #0ch    ;
871
 
872
        ajmp upcc;
873
 
874
 
875
error5:
876
        ljmp error;
877
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
878
;
879
; auto reload mode, up/down counter
880
;
881
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
882
;
883
; up counter
884
;
885
upcc:
886
        mov t2con, #02h ; t/c 2 in auto reload mode
887
        mov t2mod, #01h ;
888
        setb p3.2       ;
889
        mov th2, #000h  ;load timer 2
890
        mov tl2, #000h  ;
891
        mov rcap2l, #33h;
892
        mov rcap2h, #44h;
893
        setb tr2        ;start timer 2;
894
        cpl p3.5;
895
        cpl p3.5;
896
        cpl p3.5;
897
        cpl p3.5;
898
        cpl p3.5;
899
        cpl p3.5;
900
        cpl p3.5;
901
        cpl p3.5;
902
        clr tr2         ;stop timer 2
903
        mov b, #11h     ; error 11
904
        mov r3, #000h   ;
905
        mov r4, #004h   ;
906
        acall test2     ;
907
 
908
        mov tl2, #0fch  ; load timer 2
909
        setb tr2        ; start timer 2
910
        cpl p3.5;
911
        cpl p3.5;
912
        cpl p3.5;
913
        cpl p3.5;
914
        cpl p3.5;
915
        cpl p3.5;
916
        cpl p3.5;
917
        cpl p3.5;
918
        cpl p3.5;
919
        cpl p3.5;
920
        clr tr2         ; stop timer 2
921
        mov b, #12h     ; error 12
922
        mov r3, #001h   ;
923
        mov r4, #001h   ;
924
        acall test2     ;
925
 
926
        mov b, #13h     ; error 13
927
        jb  tf2, error5 ;
928
        clr tf2 ;
929
 
930
        mov b, #14h     ; error 14
931
        jb  exf2, error5;
932
 
933
        mov tl2, #0fch  ;
934
        mov th2, #0ffh  ;
935
        setb tr2        ;start timer 2
936
        cpl p3.5;
937
        cpl p3.5;
938
        cpl p3.5;
939
        cpl p3.5;
940
        cpl p3.5;
941
        cpl p3.5;
942
        cpl p3.5;
943
        cpl p3.5;
944
        cpl p3.5;
945
        cpl p3.5;
946
        cpl p3.5;
947
        cpl p3.5;
948
        clr tr2         ;stop timer 2
949
        mov b, #15h     ; error 15
950
        mov r3, #044h   ;
951
        mov r4, #035h   ;
952
        acall test2     ;
953
 
954
        mov b, #16h     ; error 16
955
        jnb tf2, error6 ;
956
        clr tf2 ;
957
 
958
        mov b, #17h     ; error 17
959
        jnb exf2, error6;
960
 
961
 
962
        mov tl2, #0fch  ;
963
        mov th2, #0ffh  ;
964
        setb tr2        ;start timer 2
965
        cpl p3.5;
966
        cpl p3.5;
967
        cpl p3.5;
968
        cpl p3.5;
969
        cpl p3.5;
970
        cpl p3.5;
971
        cpl p3.5;
972
        cpl p3.5;
973
        cpl p3.5;
974
        cpl p3.5;
975
        cpl p3.5;
976
        cpl p3.5;
977
        clr tr2         ;stop timer 2
978
 
979
        mov b, #18h     ; error 18
980
        jb exf2, error6 ;
981
        clr exf2        ;
982
        clr tf2 ;
983
 
984
        mov a, rcap2l   ;
985
        mov psw, #00h   ;
986
        mov b, #0f2h    ;error f2
987
        subb a, #33h    ;
988
        jnz error6      ;
989
        mov a, rcap2h   ;
990
        subb a, #44h    ;
991
        jnz error6      ;
992
 
993
        mov p0, #0dh    ;
994
 
995
        ajmp downc;
996
 
997
error6:
998
        ljmp error;
999
 
1000
;
1001
; down counter
1002
;
1003
downc:
1004
        mov t2con, #02h ; t/c 2 in auto reload mode
1005
        mov t2mod, #01h ;
1006
        clr p3.2        ;
1007
        mov th2, #0e2h  ;load timer 2
1008
        mov tl2, #048h  ;
1009
        mov rcap2l, #11h;
1010
        mov rcap2h, #22h;
1011
        setb tr2        ;start timer 2;
1012
        cpl p3.5;
1013
        cpl p3.5;
1014
        cpl p3.5;
1015
        cpl p3.5;
1016
        cpl p3.5;
1017
        cpl p3.5;
1018
        cpl p3.5;
1019
        cpl p3.5;
1020
        clr tr2         ;stop timer 2
1021
        mov b, #19h     ; error 19
1022
        mov r3, #0e2h   ;
1023
        mov r4, #044h   ;
1024
        acall test2     ;
1025
 
1026
        mov tl2, #01h   ; load timer 2
1027
        setb tr2        ; start timer 2
1028
        cpl p3.5;
1029
        cpl p3.5;
1030
        cpl p3.5;
1031
        cpl p3.5;
1032
        cpl p3.5;
1033
        cpl p3.5;
1034
        cpl p3.5;
1035
        cpl p3.5;
1036
        cpl p3.5;
1037
        cpl p3.5;
1038
        clr tr2         ; stop timer 2
1039
        mov b, #1ah     ; error 1a
1040
        mov r3, #0e1h   ;
1041
        mov r4, #0fch   ;
1042
        acall test2     ;
1043
 
1044
        mov b, #1bh     ; error 1b
1045
        jb  tf2, error6 ;
1046
        clr tf2 ;
1047
 
1048
        mov b, #1ch     ; error 1c
1049
        jb  exf2, error6;
1050
 
1051
        mov tl2, #012h  ;
1052
        mov th2, #022h  ;
1053
        setb tr2        ;start timer 2
1054
        cpl p3.5;
1055
        cpl p3.5;
1056
        cpl p3.5;
1057
        cpl p3.5;
1058
        cpl p3.5;
1059
        cpl p3.5;
1060
        cpl p3.5;
1061
        cpl p3.5;
1062
        cpl p3.5;
1063
        cpl p3.5;
1064
        cpl p3.5;
1065
        cpl p3.5;
1066
        clr tr2         ;stop timer 2
1067
        mov b, #1dh     ; error 1d
1068
        mov r3, #0ffh   ;
1069
        mov r4, #0fbh   ;
1070
        acall test2     ;
1071
 
1072
        mov b, #1eh     ; error 1e
1073
        jnb tf2, error7 ;
1074
        clr tf2 ;
1075
 
1076
        mov b, #1fh     ; error 1f
1077
        jnb exf2, error7;
1078
 
1079
 
1080
        mov tl2, #012h  ;
1081
        mov th2, #022h  ;
1082
        setb tr2        ;start timer 2
1083
        cpl p3.5;
1084
        cpl p3.5;
1085
        cpl p3.5;
1086
        cpl p3.5;
1087
        cpl p3.5;
1088
        cpl p3.5;
1089
        cpl p3.5;
1090
        cpl p3.5;
1091
        cpl p3.5;
1092
        cpl p3.5;
1093
        cpl p3.5;
1094
        cpl p3.5;
1095
        clr tr2         ;stop timer 2
1096
 
1097
        mov b, #18h     ; error 18
1098
        jb exf2, error7 ;
1099
        clr exf2        ;
1100
        clr tf2 ;
1101
 
1102
        mov a, rcap2l   ;
1103
        mov psw, #00h   ;
1104
        mov b, #04h     ;error f3
1105
        subb a, #11h    ;
1106
        jnz error7      ;
1107
        mov a, rcap2h   ;
1108
        subb a, #22h    ;
1109
        jnz error7      ;
1110
 
1111
        mov p0, #0eh    ;
1112
 
1113
        ajmp bratec;
1114
 
1115
 
1116
 
1117
error7:
1118
        ljmp error;
1119
 
1120
 
1121
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1122
;
1123
; baud rate generator
1124
;
1125
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1126
bratec:
1127
        mov t2con, #12h ; t/c 2 in baud rate generator mode
1128
        mov th2, #000h  ;load timer 2
1129
        mov tl2, #000h  ;
1130
        mov rcap2l, #11h;
1131
        mov rcap2h, #22h;
1132
        setb tr2        ;start timer 2;
1133
        cpl p3.5;
1134
        cpl p3.5;
1135
        cpl p3.5;
1136
        cpl p3.5;
1137
        cpl p3.5;
1138
        cpl p3.5;
1139
        cpl p3.5;
1140
        cpl p3.5;
1141
        clr tr2         ;stop timer 2
1142
        mov b, #20h     ; error 20
1143
        mov r3, #000h   ;
1144
        mov r4, #004h   ;
1145
        acall test2     ;
1146
 
1147
        mov tl2, #0fch  ; load timer 2
1148
        setb tr2        ; start timer 2
1149
        cpl p3.5;
1150
        cpl p3.5;
1151
        cpl p3.5;
1152
        cpl p3.5;
1153
        cpl p3.5;
1154
        cpl p3.5;
1155
        cpl p3.5;
1156
        cpl p3.5;
1157
        cpl p3.5;
1158
        cpl p3.5;
1159
        clr tr2         ; stop timer 2
1160
        mov b, #021h    ; error 21
1161
        mov r3, #001h   ;
1162
        mov r4, #001h   ;
1163
        acall test2     ;
1164
 
1165
        mov b, #22h     ; error 22
1166
        jb  tf2, error7 ;
1167
        clr tf2 ;
1168
 
1169
 
1170
        mov tl2, #0fch  ;
1171
        mov th2, #0ffh  ;
1172
        setb tr2        ;start timer 2
1173
        cpl p3.5;
1174
        cpl p3.5;
1175
        cpl p3.5;
1176
        cpl p3.5;
1177
        cpl p3.5;
1178
        cpl p3.5;
1179
        cpl p3.5;
1180
        cpl p3.5;
1181
        cpl p3.5;
1182
        cpl p3.5;
1183
        clr tr2         ;stop timer 0
1184
        mov b, #23h     ; error 23
1185
        mov r3, #022h   ;
1186
        mov r4, #013h   ;
1187
        acall test2     ;
1188
 
1189
        mov b, #24h     ; error 24
1190
        jb tf2, error8  ;
1191
        clr tf2 ;
1192
 
1193
 
1194
        mov a, rcap2l   ;
1195
        mov psw, #00h   ;
1196
        mov b, #0f4h    ;error f4
1197
        subb a, #11h    ;
1198
        jnz error8      ;
1199
        mov a, rcap2h   ;
1200
        subb a, #22h    ;
1201
        jnz error8      ;
1202
 
1203
        mov p0, #0fh;
1204
 
1205
 
1206
;
1207
; test exen2
1208
;
1209
        mov tl2, #56h   ;
1210
        mov th2, #78h   ;
1211
        setb p3.2       ;
1212
        clr p3.2        ;
1213
        setb p3.2       ;
1214
        mov a, #10h     ;
1215
loop11: nop             ;
1216
        dec a           ;
1217
        jnz loop11      ;
1218
 
1219
        mov b, #25h     ; error 25
1220
        mov r3, #078h   ;
1221
        mov r4, #056h   ;
1222
        lcall test2     ;
1223
 
1224
        mov b, #0eh     ; error e
1225
        jb exf2, error8 ;
1226
        clr exf2        ;
1227
 
1228
        setb exen2      ;
1229
        clr p3.2        ;
1230
        setb p3.2       ;
1231
        mov a, #10h     ;
1232
loop12: nop             ;
1233
        dec a           ;
1234
        jnz loop12      ;
1235
 
1236
        mov b, #26h     ; error 26
1237
        mov r3, #078h   ;
1238
        mov r4, #056h   ;
1239
        lcall test2     ;
1240
 
1241
        mov b, #27h     ;error 27
1242
        jnb exf2, error8;
1243
        clr exf2        ;
1244
 
1245
        mov p0, #10h    ;
1246
 
1247
        ajmp finish     ;
1248
 
1249
error8:
1250
        ljmp error;
1251
 
1252
 
1253
 
1254
 
1255
finish:
1256
        nop;
1257
        nop;
1258
        ajmp finish;
1259
 
1260
 
1261
 
1262
end
1263
 
1264
 
1265
 
1266
 

powered by: WebSVN 2.1.0

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