下面是怎么网上帖子,是信号发生器的一种程序,请哪位熟悉的朋友给标注一下,我还是有些看不懂,只不过有个语法错误我可以看出来
是MOV R6,R3 MOV R7,R4
我全部修改成 MOV A,R3 MOV R6,A MOV A,R4 MOV R7,A
仿真运行,P1。0 确实可以产生方波,但是调节是怎么原理,看不出来,请高手给参谋一下。谢谢了。
;方波信号发生器 ;98周志明 ;频率范围0.09Hz-99.9KHz ORG 0 SJMP MAIN ORG 000BH LJMP PTF0 MAIN: MOV SP,#06FH MOV 50H,#0 ;计算用 MOV 51H,#0 ;有效数字1 MOV 52H,#01h MOV 53H,#0 MOV 54H,#0 ;*1倍率 MOV A,54H CJNE A,#0,ZZM1 ZZM0: MOV A,51H CJNE A,#0,ZZM01 MOV A,52H CJNE A,#0,ZZM02 MOV R0,#111 MOV R1,#1 MOV TL0,#0B0H MOV TH0,#3CH LJMP TIMES ZZM02: MOV 51H,52H MOV 52H,53H MOV 53H,#0 LCALL IDTB LCALL YY LCALL NDIV1 MOV A,#0FFH SUBB A,R5 MOV TL0,A MOV A,#0FFH SUBB A,R4 MOV TH0,A MOV R0,#50 MOV R1,#10 LJMP TIMES ZZM01: LCALL IDTB LCALL YY LCALL NDIV1 MOV A,#0FFH SUBB A,R5 MOV TL0,A MOV A,#0FFH SUBB A,R4 MOV TH0,A MOV R0,#50 MOV R1,#1 LJMP TIMES ZZM1: MOV A,54H CJNE A,#01H,ZZM2 MOV A,51H CJNE A,#0,ZZM11 MOV A,52H CJNE A,#0,ZZM12 MOV 51H,53H MOV 53H,#0 LCALL IDTB LCALL YY LCALL NDIV1 MOV A,#0FFH SUBB A,R5 MOV TL0,A MOV A,#0FFH SUBB A,R4 MOV TH0,A MOV R0,#50 MOV R1,#10 LJMP TIMES ZZM12: MOV 51H,52H MOV 52H,53H MOV 53H,#0 LCALL IDTB LCALL YY LCALL NDIV1 MOV A,#0FFH SUBB A,R5 MOV TL0,A MOV A,#0FFH SUBB A,R4 MOV TH0,A MOV R0,#50 MOV R1,#1 LJMP TIMES ZZM11: LCALL IDTB LCALL YY LCALL NDIV1 MOV A,#0FFH SUBB A,R5 MOV TL0,A MOV A,#0FFH SUBB A,R4 MOV TH0,A MOV R0,#5 MOV R1,#1 LJMP TIMES ZZM2: MOV A,54H CJNE A,#02H,ZZM3 MOV A,51H CJNE A,#0,ZZM21 MOV A,52H CJNE A,#0,ZZM22 MOV 51H,53H MOV 53H,#0 LCALL IDTB LCALL YY LCALL NDIV1 MOV A,#0FFH SUBB A,R5 MOV TL0,A MOV A,#0FFH SUBB A,R4 MOV TH0,A MOV R0,#50 MOV R1,#1 LJMP TIMES ZZM22: MOV 51H,52H MOV 52H,53H MOV 53H,#0 LCALL IDTB LCALL YY LCALL NDIV1 MOV A,#0FFH SUBB A,R5 MOV TL0,A MOV A,#0FFH SUBB A,R4 MOV TH0,A MOV R0,#5 MOV R1,#1 LJMP TIMES ZZM21: LCALL IDTB MOV R6,R3 MOV R7,R4 MOV R2,#0 MOV R3,#07H MOV R4,#0A1H MOV R5,#20H LCALL NDIV1 MOV A,#0FFH SUBB A,R5 MOV TL0,A MOV A,#0FFH SUBB A,R4 MOV TH0,A MOV R0,#1 MOV R1,#1 LJMP TIMES ZZM3: MOV A,54H CJNE A,#03H,ZZM4 MOV A,51H CJNE A,#0,ZZM31 MOV A,52H CJNE A,#0,ZZM32 MOV 52H,53H MOV 53H,#0 LCALL IDTB LCALL Z LCALL NDIV1 MOV A,#0FFH SUBB A,R5 MOV TL0,A MOV A,#0FFH SUBB A,R4 MOV TH0,A MOV R0,#5 MOV R1,#1 LJMP TIMES ZZM32: LCALL IDTB MOV R6,R3 MOV R7,R4 MOV R2,#0 MOV R3,#0 MOV R4,#0C3H MOV R5,#50H LCALL NDIV1 AAAA: MOV A,#0FFH SUBB A,R5 MOV TL0,A MOV A,#0FFH SUBB A,R4 MOV TH0,A MOV R0,#1 MOV R1,#1 LJMP TIMES ZZM31: LCALL IDTB MOV R6,R3 MOV R7,R4 MOV R2,#0 MOV R3,#0 MOV R4,#0c3H MOV R5,#50H LCALL NDIV1 SJMP AAAA ZZM4: LCALL IDTB MOV R6,R3 MOV R7,R4 MOV R2,#0 MOV R3,#0 MOV R4,#13H MOV R5,#88H LCALL NDIV1 MOV A,#0FFH SUBB A,R5 MOV TL0,A MOV A,#0FFH SUBB A,R4 MOV TH0,A MOV R0,#1 MOV R1,#1 LJMP TIMES IDTB: MOV R0,#50H MOV R2,#3 MOV R3,#0 MOV A,@R0 MOV R4,A LOOP: MOV A,R4 MOV B,#10 MUL AB MOV R4,A MOV A,B XCH A,R3 MOV B,#10 MUL AB ADD A,R3 MOV R3,A INC R0 MOV A,R4 ADD A,@R0 MOV R4,A MOV A,R3 ADDC A,#0 MOV R3,A DJNZ R2,LOOP RET YY: MOV R6,R3 MOV R7,R4 MOV R2,#0 MOV R3,#0FH MOV R4,#42H MOV R5,#40H RET Z: MOV R6,R3 MOV R7,R4 MOV R2,#0 MOV R3,#01H MOV R4,#86H MOV R5,#0A0H RET NDIV1: MOV A,R3 CLR A SUBB A,R7 MOV A,R2 SUBB A,R6 JNC NDVE1 MOV B,#16 NDVL1: CLR C MOV A,R5 RLC A MOV R5,A MOV A,R4 RLC A MOV R4,A MOV A,R3 RLC A MOV R3,A XCH A,R2 RLC A XCH A,R2 MOV F0,C CLR C SUBB A,R7 MOV R1,A MOV A,R2 SUBB A,R6 JB F0,NDVM1 JC NDVD1 NDVM1: MOV R2,A MOV A,R1 MOV R3,A INC R5 NDVD1: DJNZ B,NDVL1 CLR F0 RET NDVE1: SETB F0 RET TIMES: MOV TMOD,#1 MOV IP,#2 MOV IE,#82H MOV 30H,TL0 MOV 31H,TH0 MOV 32H,R0 MOV 33H,R1 SETB P1.0 SETB TR0 AAA: SJMP AAA PTF0: DJNZ R0,PTF1 MOV R0,32H DJNZ R1,PTF1 CPL P1.0 MOV R1,33H ptf1: mov a,30h orl tl0,a mov th0,31h PTF0R: RETI END |