数字频率计的程序,可能是天书了拉,参考一下
你得先从程序中揣模原创的硬件,有耐心的话是可以画出原文原理图的.有一部分注解,哈哈,比没有好一点.嫌费劲就扔掉,俺可是花时间整理了一番.
ORG 0000H AJMP MAIN ORG 000BH LJMP SEVER1 ORG 0030H
MAIN: A8279_1 EQU 0FF82H A8279_2 EQU 0FF80H
MOV DPTR,#A8279_1 ;8279初始化 MOV A,#0D1H MOVX @DPTR,A WAIT1: MOVX A,@DPTR JB ACC.7,WAIT1 MOV A,#00H MOVX @DPTR,A MOV A,#2CH MOVX @DPTR,A 00H CLR 01H CLR 02H CLR 03H CLR 04H CLR 05H CLR 06H CLR 07H CLR 08H CLR 09H START: MOV DPTR,#A8279_1 MOVX A,@DPTR ANL A,#07H JZ RETUN ACALL KEY JBC 00H,MAIN JBC 01H,START1 JBC 02H,START2 JBC 03H,START3 JBC 04H,START4 ETUN: AJMP START TART1: MOV P1,#0EFH LCALL SEACH1 JBC 00H,MAIN JBC 06H,PINYU61 JBC 07H,PINYU71 JBC 08H,PINYU81 JBC 09H,PINYU91 AJMP START1 PINYU61: LJMP PINYU6 PINYU71: LJMP PINYU7 PINYU81: LJMP PINYU8 PINYU91: LJMP PINYU9 START2: MOV P1,#2FH LCALL SEACH1 JBC 00H,MAIN JBC 06H,ZHOUQI11 JBC 07H,ZHOUQI21 JBC 08H,ZHOUQI31 JBC 09H,RETUN4 RETUN4: AJMP START2 ZHOUQI11: AJMP ZHOUQI1 ZHOUQI21: AJMP ZHOUQI2 ZHOUQI31: AJMP ZHOUQI3
START3: LCALL SEACH1 JBC 00H ,RETUN16 LCALL CEMK AJMP START3 ETUN16: LJMP MAIN START4: LCALL SEACH1 JBC 00H,RETUN15 LCALL CEZHANKB AJMP START4 RETUN15: LJMP MAIN INYU6: LCALL SEACH1 JBC 00H,RETUN11 MOV P1,#1EH LCALL ZHQI LCALL PINYU1 LCALL TRANS LCALL LED AJMP PINYU6 RETUN11: AJMP MAIN INYU7: LCALL SEACH1 JBC 00H,RETUN12 MOV P1,#1DH LCALL CZS
LCALL PINYU2 LCALL TRANS LCALL LED AJMP PINYU7 RETUN12: AJMP MAIN INYU8: LCALL SEACH1 JBC 00H,RETUN13 MOV P1,#1BH LCALL CZS MOV 35H,#08H LCALL PINYU LCALL TRANS LCALL LED AJMP PINYU8 ETUN13: AJMP MAIN INYU9: LCALL SEACH1 JBC 00H,RETUN14 MOV P1,#17H LCALL CZS MOV 35H,#32 LCALL PINYU LCALL TRANS LCALL LED AJMP PINYU9 RETUN14: LJMP MAIN HOUQI1: MOV P1,#2EH LCALL ZHQI LCALL MUL4 LCALL ADD1 MOV 60H,R2 MOV 61H,R3 MOV 62H,R4 MOV 63H,R5 LCALL TRANS LCALL LED AJMP ZHOUQI1 HOUQI2: MOV P1,#2DH LCALL SEACH1 JBC 00H ,RETUN9 LCALL ZHOUQI2_2 MOV 36H,R3 MOV 37H,R4 MOV 38H,R5 LCALL HB4 ;转换后的三字节BCD码整数在R2,R3、R4、R5中。 MOV 60H,R2 MOV 61H,R3 MOV 62H,R4 MOV 63H,R5 LCALL TRANS LCALL LED AJMP ZHOUQI2 ETUN9: LJMP MAIN HOUQI3: MOV P1,#2BH LCALL SEACH1 JBC 00H,RETUN10 LCALL ZHOUQI2_2 MOV 36H,R3 MOV 37H,R4 MOV 38H,R5 MOV R0,#36H MOV R7,#08H ;分频系数 LCALL MULD3_1 MOV 60H,R2 MOV 61H,R3 MOV 62H,R4 MOV 63H,R5 LCALL TRANS LCALL LED AJMP ZHOUQI3 RETUN10: AJMP MAIN HOUQI2_2: LCALL CZS MOV A,76H ; CJNE A,#00H,NEXT12 ; AJMP NEXT13
LCALL MUL4 LCALL ADD1 MOV 60H,R2 LCALL MUL4 MOV 61H,R3 LCALL ADD1 MOV 62H,R4 MOV 63H,R5 CJNE R3,#00H,NEXT14 MOV 76H,#01H MOV 69H,76H AJMP NEXT15 NEXT14: JC NEXT15 MOV 76H,#08H MOV 69H,76H MOV R7,#08H LCALL DV31 ;双字节商在R4、R5中 MOV 62H,R4 MOV 63H,R5 NEXT15: MOV A,R4 MOV R6,A MOV A,R5 MOV R7,A MOV R2,#00H MOV R3,#0FH MOV R4,#42H MOV R5,#40H LCALL DIVD ; 双字节商在R2、R3中,OV=1 时溢出 MOV 62H,R2 MOV 63H,R3 MOV R6,#00H MOV R7,76H JNB OV,NEXT16 MOV R6,62H MOV R7,63H MOV R2,#00H ;存入10000 MOV R3,#00H MOV R4,#27H MOV R5,#10H LCALL DIVD ; 双字节商在R2、R3中,OV=1 时溢出 EXT16: MOV A,69H CJNE A,#01H,NEXT32 AJMP NEXT33 NEXT32: MOV R6,#00H MOV R7,#69H LCALL DIVD EXT33: MOV R7,#64H MOV R6,#00H LCALL MULD ;:乘积在R2、R3、R4、R5中。 RET
CEMK: MOV P1,#4DH LCALL MAIKUAN LCALL HB4 ;转换后的三字节BCD码整数在R2,R3、R4、R5中。 MOV 60H,R2 MOV 61H,R3 MOV 62H,R4 MOV 63H,R5
LCALL TRANS LCALL LED RET EZHANKB: MOV P1,#8DH LCALL ZHQI LCALL MUL4 LCALL ADD1 ; ;结果在R2.R3.R4.R5中 MOV 70H,R2 MOV 71H,R3 MOV 72H,R4 MOV 73H,R5
LCALL MAIKUAN ;;结果在36,37,38H中 MOV R6,37H MOV R7,38H MOV R2,#03H MOV R3,#0E8H LCALL MULD ; 乘积在R2、R3、R4、R5中。 MOV R6,72H MOV R7,73H LCALL DIVD ; 双字节商在R2、R3中,OV=1 时溢出。 MOV R2,72H MOV R3,73H MOV R6,72H MOV R7,73H LCALL HB2 ;转换后的三字节BCD码整数在R3、R4、R5中。 MOV 60H,#00H MOV 61H,R3 MOV 62H,R4 MOV 63H,R5 LCALL TRANS LCALL LED RET
EY: MOV DPTR,#A8279_1 MOV A,#40H MOVX @DPTR,A MOV DPTR,#A8279_2 MOVX A,@DPTR ANL A,#3FH
CJNE A,#00H,KEY1 SETB 00H LJMP RETUN1 KEY1: CJNE A,#01H,KEY2 SETB 01H LJMP RETUN1 KEY2: CJNE A,#02H,KEY3 SETB 02H AJMP RETUN1 KEY3: CJNE A,#03H,KEY4 SETB 03H LJMP RETUN1
KEY4: CJNE A,#04H,KEY5 SETB 04H LJMP RETUN1 KEY5: CJNE A,#05H,RETUN1 SETB 05H
RETUN1: RET KEY_1: MOV DPTR ,#A8279_1 MOV A,#40H MOVX @DPTR,A MOV DPTR,#A8279_2 MOVX A,@DPTR ANL A,#3FH
CJNE A,#00H,KEY_11 SETB 00H LJMP RETUN2 KEY_11: CJNE A,#06H,KEY_12 SETB 06H LJMP RETUN2 KEY_12 :CJNE A,#07H,KEY_13 SETB 07H AJMP RETUN2 KEY_13: CJNE A,#08H,KEY_14 SETB 08H LJMP RETUN2
KEY_14: CJNE A,#09H,RETUN2 SETB 09H
RETUN2: RET ZHQI: ;0.1hz_1khz测量,测周期 ;16进制 MOV TMOD,#01H MOV TL0,#00H MOV TH0,#00H SETB EA SETB ET0 MOV 76H,#00H SETB P3.5 GDP1: MOV C,P3.5 JC GDP1 DDP1: MOV C,P3.5 JNC DDP1 SETB TR0
GDP2: MOV C,P3.5 JC GDP2 DDP2: MOV C,P3.5 JNC DDP2 CLR TR0 CLR TR1 MOV A,TH0 MOV TH1,A MOV A,TL0 MOV TL1,A RET
PINYU1: ;0.1hz_1khz测量;结果在让,r4,r5 中 ;16进制 LCALL MUL4 LCALL ADD1 MOV 30H,#00H MOV 31H,#00H MOV 32H,#0FFH MOV 33H,#0FFH LCALL BIJIAO JB 20H,BIJIAO2 MOV 34H,R4 MOV 35H,R5 MOV R6,34H MOV R7,35H MOV R2,#00H MOV R3,#0FH MOV R4,#42H MOV R5,#40H LCALL DIVD ; OV=0 时,双字节商在R2、R3中,OV=1 时溢出。 MOV A,R2 MOV R6,A MOV A,R3 MOV R7,A AJMP NEXT30 IJIAO2: MOV 30H,#00H MOV 31H,#0FH MOV 32H,#42H MOV 33H,#40H LCALL BIJIAO JB 20H,BIJIAO3 MOV R7,#100 LCALL DV31 ;OV=0 时,双字节商在R4、R5中,OV=1 时溢出。 MOV 34H,R4 MOV 35H,R5 MOV R6,34H MOV R7,35H MOV R2,#00H MOV R3,#0FH MOV R4,#42H MOV R5,#40H LCALL DIVD ; OV=0 时,双字节商在R2、R3中,OV=1 时溢出。 MOV 34H,R2 MOV 35H,R3 MOV R6,34H MOV R7,35H MOV R3,#00H MOV R4,34H MOV R5,35H MOV R7,#100 LCALL DV31 ;OV=0 时,双字节商在R4、R5中,OV=1 时溢出。 MOV 34H,R4 MOV 35H,R5 MOV R6,34H MOV R7,35H AJMP NEXT30 IJIAO3: MOV R7,#0E8H MOV R6,#03H LCALL DIVD ; OV=0 时,双字节商在R2、R3中,OV=1 时溢出。 MOV 34H,R2 MOV 35H,R3 MOV R6,34H MOV R7,35H MOV R2,#00H MOV R3,#98H MOV R4,#96H MOV R5,#80H LCALL DIVD ; OV=0 时,双字节商在R2、R3中,OV=1 时溢出。 MOV 34H,R2 MOV 35H,R3 MOV R6,34H MOV R7,35H MOV R2,#00H MOV R3,#00H MOV R4,34H MOV R5,35H MOV R7,#0E8H MOV R6,#03H LCALL DIVD ; OV=0 时,双字节商在R2、R3中,OV=1 时溢出。 MOV 34H,R2 MOV 35H,R3 MOV R6,34H MOV R7,35H NEXT30: LCALL HB2 MOV 60H,#00H MOV 61H,R3 MOV 62H,R4 MOV 63H,R5 CLR ET0 RET SEVER1: INC 76H RETI ZS: ;测1秒钟的周期数 MOV TMOD,#51H MOV TL0,#00H MOV TH0,#4CH MOV 76H,#00H MOV R7,#14H
MOV TL1,#00H MOV TH1,#00H SETB TR1 SETB TR0 HERE: JBC TF0 ,NEXT1 JBC TF1,NEXT20 SJMP HERE EXT20: INC 76H AJMP HERE EXT1: MOV TL0,#00H MOV TH0,#4CH DJNZ R7,HERE CLR TR0 CLR TR1 RET
PINYU2: ;测频率1k_0.5mhz MOV A,76H CJNE A,#00H,NEXT2 MOV 65H,#00H MOV 66H,#00H MOV 67H,#00H AJMP NEXT3 EXT2: MOV R6,76H MOV R0,#65H MOV R7,#03H MOV R1,#50H & |
|