简单的可以使用555模块 这个芯片是外接模拟器件来控制输出方波频率的 输出端加滤波器或者积分器就可以实现三种波形 555的讲解非常多 希望对你有帮助
设计任务 设计一个能产生正弦波 方波 三角波三种波形的信号发生器
ORG 1000H
START:MOV A,#00H
BEGIN:MOV R2,A
MOV A,P1
SUB:CJNE A,#0FEH,SINA;P1.0=0调用方波子程序:SUB,P1.0=1转移到三波:SINA
LCALL SUB
SINA:CJNE A,#0FDH,JUCHI;P1.1=0调用三角波子程序:SINA,P1.1=1转移到锯齿波:JUCHI
LCALL SINA
JUCHI:CJNE A,#0FBH,JIETI;P1.2=0调用锯齿波子程序;JUCHI,P1.2=1转移到阶梯波:JIET
LCALL JUCHI
JIETI:CJNE A,#0F7H, Loopd0;P1.3=0调用阶梯波子程序:JIETI,P1.3=1转移到BACK返回
LCALL JIETI
Loopd0:cjne a,#oefh,back
Lcall zhengxianbo
BACK:LJMP BEGIN
END;------------------------------------------------;子程序名称:SUB
子程序功能: 调用方波子程序
;入口参数:
;出口参数:
;占用资源:;-------------------------------------------------
SUB:MOV DPTR,#7FFFH
NEXT:MOV A,#0
MOV P0,A
ACALL D1MS1
NEXT1:MOV A,#0FFH
MOV P0,A
ACALL D1MS1
SJMP NEXT
D1MS1:MOV R1,#0F5H
DELAY1:MOV R2,#0FFH
DELAY2:DJNZ R2,DELAY2
DJNZ R1,DELAY2
RET;-------------------------------------子程序名称: SINA子程序功能: 调用三角波子程序
;入口参数:
;出口参数:
;占用资源:;-------------------------------------
SINA:MOV DPTR,#7FFFH
SETP1:MOV A, #00H
SETP2:MOV P0 ,A
NOP
NOP
INC A
JNZ STEP2
SETP3:DEC A
MOV P0,A
NOP
NOP
JNZ SETP3
RET----------------------------------------
子程序名称: JIETI
子程序功能: 调用梯形波子程序
;入口参数:
;出口参数:
;占用资源:;--------------------------------------
JIETI: MOV DPTR,#7FFFH
STEP1:MOV A,#00H
STEP2:MOV P0,A
ACALL D1MS3
D1MS3:MOV R7,#153
DJNZ R7,$
ADD A,#33H
CJNE A,#0FFH,STEP3
STEP3:MOV P0,A
ACALL D5MS4
SJMP STEP1
D5MS4:MOV R7,#255
DJNZ R7,$
REt;----------------------------------------子程序名称: JUCHI
;子程序功能: 调用锯齿波子程序
;入口参数:
;出口参数:
;占用资源:;----------------------------------------
JUCHI: MOV DPTR,#7FFFH
STEP:MOV A,#00H
LOOP0:MOV P0,A
LOOP1:INC A
MOV P0,A
CJNE A,#FFH,LOOP1
SJMP STEP
Loopd0: MOV DPTR,#sinTab
LOOPd1: CLR A
MOVC A,@A+DPTR
CJNE A,#129,LOOP1
RET
LOOPd2: MOV P0,A
INC DPTR
AJMP LOOP
sinTab:DB 128,132,137,141,146,150,154,159,163,167
DB 171,176,180,184,188,191,195,199,203,206
DB 210,213,216,219,222,225,228,231,233,236
DB 238,240,242,244,246,247,249,250,251,252
DB 253,254,254,255,255,255,255,255,254,254
DB 253,252,251,250,249,247,246,244,242,240
DB 238,236,233,231,228,225,222,219,216,213
DB 210,206,203,198,195,192,188,184,180,176
DB 172,167,163,159,155,150,146,141,137,133
DB 128,124,119,115,111,106,102,97,93,89,85
DB 81,77,73,69,65,61,57,54,50,47,43,40,37
DB 34,31,28,25,23,20,18,16,14,12,10,9,7
DB 6,5,4,3,2,2,1,1,1,1,1,2,2,3,4,5,6
DB 7,9,10,12,14,16,18,20,23,25,28,30,33,36
DB 40,43,46,50,53,57,60,64,68,72,76,80,84
DB 88,93,97,101,106,110,114,119,123,128,129
RET