求基于单片机和DAC0832制作的信号发生器,有电路图和c语言程序,能实现功能,邮箱qtpjw@126.com

2024-12-29 18:40:03
推荐回答(2个)
回答1:

做过。我现在发一个类似的,是别人的,正好被我看到了,你可以参考一下。
ORG 0000H
LJMP MAIN
ORG 0100H
MAIN: JNB P1.0,P10
JNB P1.1,P11
JNB P1.2,P12
JNB P1.3,P13
LJMP MAIN

P10: MOV R7,#00H
LCALL SQU
LJMP MAIN
P11: MOV R7,#01H
LCALL SAW
LJMP MAIN
P12: MOV R7,#02H
LCALL TRI
LJMP MAIN
P13: MOV R7,#03H
LCALL SIN
LJMP MAIN

SQU: JNB P1.1,N1
JNB P1.2,N2
JNB P1.3,N3
LJMP SSQU
N1: MOV R7,#01H
LJMP TC0
N2: MOV R7,#02H
LJMP TC0
N3: MOV R7,#03H
LJMP TC0
SSQU: CJNE R7,#00H,TC0

MOV R0,#00H
MOV DPTR,#7FFFH
K00: MOV A,#0FFH
MOVX @DPTR,A
MOV P0,#0FFH
MOV P2,#0FFH
MOV A,P2
CPL A
MOV R3,A
L00: DEC R3
CJNE R3,#255,L00
INC R0
INC R0
CJNE R0,#254,K00
MOV R0,#00H
K01: MOV A,#00H
MOVX @DPTR,A
MOV P0,#00H
MOV P2,#0FFH
MOV A,P2
CPL A
MOV R3,A

L01: DEC R3
CJNE R3,#255,L01
INC R0
INC R0
CJNE R0,#254,K01
LJMP SQU
TC0: RET

SAW: JNB P1.0,N4
JNB P1.2,N5
JNB P1.3,N6
LJMP SSAW
N4: MOV R7,#00H
LJMP TC1
N5: MOV R7,#02H
LJMP TC1
N6: MOV R7,#03H
LJMP TC1
SSAW: CJNE R7,#01H,TC1
MOV R0,#0FFH
MOV DPTR,#7FFFH
K10: MOV A,R0
MOVX @DPTR,A
MOV P0,R0
MOV P2,#0FFH
MOV A,P2
CPL A
MOV R3,A
L10: DEC R3
CJNE R3,#255,L10
INC R0
CJNE R0,#255,K10
LJMP SAW
TC1: RET

TRI: JNB P1.0,N7
JNB P1.1,N8
JNB P1.3,N9
LJMP TTRI
N7: MOV R7,#00H
LJMP TC2
N8: MOV R7,#01H
LJMP TC2
N9: MOV R7,#03H
LJMP TC2
TTRI: CJNE R7,#02H,TC2

MOV R0,#00H
MOV DPTR,#7FFFH
K20: MOV A,R0
MOVX @DPTR,A
MOV P0,R0
MOV P2,#0FFH
MOV A,P2
CPL A
MOV R3,A
L20: DEC R3
CJNE R3,#255,L20
INC R0
INC R0
CJNE R0,#254,K20
K21: MOV A,R0
MOVX @DPTR,A
MOV P0,R0
MOV P2,#0FFH
MOV A,P2
CPL A
MOV R3,A
L21: DEC R3
CJNE R3,#255,L21
DEC R0
DEC R0
CJNE R0,#0,K21
LJMP TRI
TC2: RET

SIN: JNB P1.0,N10
JNB P1.1,N11
JNB P1.2,N12
LJMP SSIN
N10: MOV R7,#00H
LJMP TC3
N11: MOV R7,#01H
LJMP TC3
N12: MOV R7,#02H
LJMP TC3
SSIN: CJNE R7,#03H,TC3

MOV R0,#00H
MOV DPTR,#7FFFH
K30: MOV A,R0
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV DPTR,#7FFFH
MOVX @DPTR,A
MOV P0,A
INC R0
MOV P2,#0FFH
MOV A,P2
CPL A
MOV R3,A
L30: DEC R3
CJNE R3,#255,L30
CJNE R0,#255,K30
LJMP SIN
TC3: RET

TAB: DB

回答2:

我来帮助你做,很简单的,可以调频率和占空比