同时显示多个数字程序~实验板上的数码管从左到右同时显示“1”、“2”、“3”

 1     DAT_74164    BIT    P0.6
 2     CLK_74164    BIT    P0.7
 3 
 4     org    0000H        
 5     jmp    MAIN
 6 
 7 ;*******************************************    
 8     org    0030H        ;Start program from 0030H        
 9 MAIN:
10     mov    P0,#0FFH      ;四个端口初始化,关闭外围
11     mov    P1,#0FFH    
12     mov    P2,#0FFH
13     mov    P3,#0FFH
14 
15 MAIN_LOOP:    
16     mov    P0,#11111110B    ;The first to show 1,位选
17     mov    a,#0F9H      ;段选,给a设一个F9:1111 1001,共阳0有效
18     call    sendTo74164    ;约等于60微秒
19     call    MIN_DELAY    ;约等于10000微秒
20 
21     mov    P0,#11111101B    ;The second to show 2
22     mov    a,#10100100B
23     call    sendTo74164
24     call    MIN_DELAY
25 
26     mov    P0,#11111011B    ;The third to show 3
27     mov    a,#10110000B
28     call    sendTo74164
29     call    MIN_DELAY
30 
31     jmp    MAIN_LOOP
32 
33     ret
34 ;*******************************************
35 ;Send data of A to chip 74LS164
36 sendTo74164:
37     push    07h
38     push    acc
39 
40     mov    r7,#08        ;send 8 bits      
41 SEND164_LOOP:
42     clr    CLK_74164    ;clear clock-line for reading data
43     rlc    a
44     mov    DAT_74164,c    ;move data-bit to data-line    
45     setb    CLK_74164    ;send data to 74164
46     djnz    r7,SEND164_LOOP
47         
48     pop    acc
49     pop    07h
50 ret
51 ;*******************************************
52 ;Dealy for a interval
53 DELAY:    
54     mov    r5,#20H
55 DELAY_2:
56     mov    R6,#0FFH    
57 DELAY_1:
58     
59     mov    R7,#0FFH
60 DELAY_0:
61     nop
62     nop
63     djnz    R7,DELAY_0
64 
65     djnz    R6,DELAY_1
66 
67     djnz    R5,DELAY_2
68 
69 ret
70 ;*******************************************
71 ;Dealy for a interval
72 MIN_DELAY: (内循环1ms)   
73     mov    R6,#8
74 DELAY_02:
75     mov    R7,#250
76 DELAY_01:
77     nop
78     nop
79     djnz    R7,DELAY_01
80     djnz    R6,DELAY_02
81 ret
82 ;*******************************************
83     END    

 

posted on 2022-10-17 17:43  罗小罗佳油  阅读(95)  评论(0编辑  收藏  举报