首页 > 编程语言 >通过movc指令选取段选码程序~6”号数码管从“0”显示到“9”

通过movc指令选取段选码程序~6”号数码管从“0”显示到“9”

时间:2022-10-17 17:47:55浏览次数:48  
标签:0FFH DELAY 74164 movc mov 30H 数码管 选码 data

 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        ;四个mov:端口初始化关闭外围
11     mov    P1,#0FFH    
12     mov    P2,#0FFH
13     mov    P3,#0FFH
14     
15     mov    30H,#00H         ;Intialize the variable ,变量30H赋值00H(30H:128个数据存储器中地址为30的)
16 DISP_LOOP:    
17     mov    a,30H              ;Get the value to display
18     mov    dptr,#TAB_LED    ;(TAB_LED中的内容加载到数据指针)给寄存器或者变量dptr赋一个数组,数组名为TAB_LED
19     movc    a,@a+dptr      ;(代码字节传送到累加器)拿序号换内容,在数组中查内容赋给a
20     call    sendTo74164        ;Display the numbet
21     mov    P0,#11011111B    ;发送位选,第几个数码管亮
22     call    delay
23 
24     mov    a,30H
25     inc    30H           ;给30H+1即30H=30H+1
26     cjne    a,#09,DISP_LOOP    ;如果a!=9则跳出循环
27     
28     jmp    $
29 
30 
31     ret
32 ;*******************************************
33 ;Send data of A to chip 74LS164
34 sendTo74164:
35     push    07h
36     push    acc
37 
38     mov    r7,#08        ;send 8 bits      
39 SEND164_LOOP:
40     clr    CLK_74164    ;clear clock-line for reading data
41     rlc    a
42     mov    DAT_74164,c    ;move data-bit to data-line    
43     setb    CLK_74164    ;send data to 74164
44     djnz    r7,SEND164_LOOP
45         
46     pop    acc
47     pop    07h
48 ret
49 ;*******************************************
50 ;Dealy for a interval
51 delay:    
52     mov    r5,#06H
53 DELAY_2:
54     mov    r6,#0FFH    
55 DELAY_1:
56     
57     mov    r7,#0FFH
58 DELAY_0:
59     nop
60     nop
61     djnz    r7,DELAY_0
62 
63     djnz    r6,DELAY_1
64 
65     djnz    r5,DELAY_2
66 
67     ret
68 ;****************************************************
69 TAB_LED:    DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
70 ;****************************************************
71     END    

solution:

1 delay 的机器周期?

标签:0FFH,DELAY,74164,movc,mov,30H,数码管,选码,data
From: https://www.cnblogs.com/luoxiaoluo/p/16799998.html

相关文章