单片机课设波形发生器调频率不可调频率汇编.docx
- 文档编号:10027153
- 上传时间:2023-02-08
- 格式:DOCX
- 页数:16
- 大小:532.20KB
单片机课设波形发生器调频率不可调频率汇编.docx
《单片机课设波形发生器调频率不可调频率汇编.docx》由会员分享,可在线阅读,更多相关《单片机课设波形发生器调频率不可调频率汇编.docx(16页珍藏版)》请在冰豆网上搜索。
单片机课设波形发生器调频率不可调频率汇编
说明:
1,内附可调频与不可调频两种代码
2,可调频中,又有两种调频思路
综合---不可调频产生五种波
ORG0000H
LJMPMAIN
ORG0003H;外部中断0
LJMPINT00
ORG0040H
MAIN:
MOVSP,60H;更改堆栈指针,避免堆栈与工作寄存器区发生冲突
SETBIT0;外部中断请求0为下降沿触发方式
SETBEA;中断允许总开关打开
SETBEX0;允许外部中断0中断
INT00:
CLREA;关中断
PUSHPSW;现场保护
PUSHAcc
SETBEA;开中断
JNBP1.0,IR0;如果K0键闭合,则跳转至IR0输出锯齿波
JNBP1.1,IR1;如果K1键闭合,则跳转至IR1输出梯形波
JNBP1.2,IR2;如果K2键闭合,则跳转至IR2输出三角波
JNBP1.3,IR3;如果K3键闭合,则跳转至IR3输出方波
JNBP1.4,IR4;如果K4键闭合,则跳转至IR4输出正弦波
INTIR:
CLREA;关中断
POPAcc;现场恢复
POPPSW
SETBEA;开中断
RETI
IR0:
MOVR0,#0FEH;设置端口地址
MOVA,#00H
LOOP:
MOVX@R0,A;写入
JBP1.0,INTIR;如果k0键已经断开,则返回
INCA;A加一
SJMPLOOP;循环
LJMPINTIR;返回
IR1:
MOVR0,#0FEH;设置端口地址
MOVA,#00H
UP:
MOVX@R0,A;写入
JBP1.1,INTIR;如果k1键已经断开,则返回
INCA;A加一
JNZUP;循环
DECA;如果已经溢出,则减一,减一之后A的值为255
LCALLDELAY;延时
JBP1.1,INTIR;如果k1键已经断开,则返回
DOWN:
DECA
MOVX@R0,A;写入
JBP1.1,INTIR;如果k1键已经断开,则返回
JNZDOWN;循环
SJMPUP;如果减到0,则跳转至UP,继续执行加一操作
LJMPINTIR;返回
DELAY:
MOVR7,#100;延时子程序
DELAY1:
MOVR6,#10
NOP
DELAY2:
DJNZR6,DELAY2
DJNZR7,DELAY1
RET
IR2:
MOVR0,#0FEH;设置端口地址
MOVA,#00H
UP2:
MOVX@R0,A;写入
JBP1.2,INTIR;如果k2键已经断开,则返回
INCA;A加一
JNZUP2;循环
DOWN2:
DECA;A减一
MOVX@R0,A;写入
JBP1.2,INTIR;如果k2键已经断开,则返回
JNZDOWN2;循环
SJMPUP2;如果减到0,则跳转至UP2,继续加一操作
LJMPINTIR;返回
IR3:
MOVR0,#0FEH;设置端口地址
POSI:
MOVA,#00H;给A赋值0x00
MOVX@R0,A;写入
LCALLDELAY;延时
JBP1.3,INTIR;如果k3键已经断开,则返回
NEGA:
MOVA,#0FFH;给A赋值0xFF
MOVX@R0,A;写入
LCALLDELAY;延时
JBP1.3,INTIR;如果k3键已经断开,则返回
SJMPPOSI;跳转至POSI,继续下一个波形的输出
LJMPINTIR;返回
IR4:
MOVR0,#0FEH;设置端口地址
MOVR1,#00H
XX:
MOVA,R1
LCALLHANSHU;调用查表函数
MOVX@R0,A;写入
JBP1.4,INTIR;如果k4键已经断开,则返回
INCR1
SJMPXX;继续查表
LJMPINTIR;返回
HANSHU:
MOVDPTR,#TAB1
MOVCA,@A+DPTR
RET
TAB1:
DB080h,083h,086h,089h,08ch,090h,093h,096h,099h,09ch,09fh,0a2h,0a5h,0a8h,0abh,0aeh
DB0b1h,0b3h,0b6h,0b9h,0bch,0bfh,0c1h,0c4h,0c7h,0c9h,0cch,0ceh,0d1h,0d3h,0d5h,0d8h
DB0dah,0dch,0deh,0e0h,0e2h,0e4h,0e6h,0e8h,0eah,0ebh,0edh,0efh,0f0h,0f1h,0f3h,0f4h
DB0f5h,0f6h,0f8h,0f9h,0fah,0fah,0fbh,0fch,0fdh,0fdh,0feh,0feh,0feh,0ffh,0ffh,0ffh
DB0ffh,0ffh,0ffh,0ffh,0feh,0feh,0feh,0fdh,0fdh,0fch,0fbh,0fah,0fah,0f9h,0f8h,0f6h
DB0f5h,0f4h,0f3h,0f1h,0f0h,0efh,0edh,0ebh,0eah,0e8h,0e6h,0e4h,0e2h,0e0h,0deh,0dch
DB0dah,0d8h,0d5h,0d3h,0d1h,0ceh,0cch,0c9h,0c7h,0c4h,0c1h,0bfh,0bch,0b9h,0b6h,0b3h
DB0b1h,0aeh,0abh,0a8h,0a5h,0a2h,09fh,09ch,099h,096h,093h,090h,08ch,089h,086h,083h
DB080h,07dh,07ah,077h,074h,070h,06dh,06ah,067h,064h,061h,05eh,05bh,058h,055h,052h
DB04fh,04dh,04ah,047h,044h,041h,03fh,03ch,039h,037h,034h,032h,02fh,02dh,02bh,028h
DB026h,024h,022h,020h,01eh,01ch,01ah,018h,016h,015h,013h,011h,010h,00fh,00dh,00ch
DB00bh,00ah,008h,007h,006h,006h,005h,004h,003h,003h,002h,002h,002h,001h,001h,000h
DB000h,000h,001h,001h,002h,002h,002h,003h,003h,004h,005h,006h,006h,007h,008h,00ah
DB00bh,00ch,00dh,00fh,010h,011h,013h,015h,016h,018h,01ah,01ch,01eh,020h,022h,024h
DB026h,028h,02bh,02dh,02fh,032h,034h,037h,039h,03ch,03fh,041h,044h,047h,04ah,04dh
DB04fh,052h,055h,058h,05bh,05eh,061h,064h,067h,06ah,06dh,070h,074h,077h,07ah,07dh
RET
END
定时调频版――正弦波
SINPDATA30H
THDDATA32H
TLDDATA33H
ORG0000H
LJMPBBK
ORG000BH
LJMPINTT0
ORG0060H
BBK:
MOVSP,#70H
MOVTHD,#0E8H
MOVTLD,#00H
MOVTMOD,#01H
MOVTH0,THD
MOVTL0,THD
START:
SETBET0
SETBEA
SETBTR0
MAIN:
JNBP1.0,INCKEY
JNBP1.1,DECKEY
LJMPSTART
INCKEY:
LCALLDL10MS
MOVA,THD
CJNEA,#0FEH,INC1
LJMPSTART
INC1:
INCTHD
LJMPSTART
DECKEY:
LCALLDL10MS
MOVA,THD
CJNEA,#0AFH,DEC1
LJMPSTART
DEC1:
DECTHD
LJMPSTART
;10MS
DL512:
MOVR7,#0FFH
LOOP:
DJNZR7,LOOP
RET
DL10MS:
MOVR6,#0A4H
LOOP1:
LCALLDL512
DJNZR6,LOOP1
RET
INTT0:
CLREA
PUSHACC
MOVA,SINP
MOVDPTR,#TAB1
MOVCA,@A+DPTR
MOVDPTR,#7FFFH
MOVX@DPTR,A;写入
INCSINP
SETBEA
POPACC
MOVTH0,THD
MOVTL0,THD
RETI
TAB1:
DB080h,083h,086h,089h,08ch,090h,093h,096h,099h,09ch,09fh,0a2h,0a5h,0a8h,0abh,0aeh
DB0b1h,0b3h,0b6h,0b9h,0bch,0bfh,0c1h,0c4h,0c7h,0c9h,0cch,0ceh,0d1h,0d3h,0d5h,0d8h
DB0dah,0dch,0deh,0e0h,0e2h,0e4h,0e6h,0e8h,0eah,0ebh,0edh,0efh,0f0h,0f1h,0f3h,0f4h
DB0f5h,0f6h,0f8h,0f9h,0fah,0fah,0fbh,0fch,0fdh,0fdh,0feh,0feh,0feh,0ffh,0ffh,0ffh
DB0ffh,0ffh,0ffh,0ffh,0feh,0feh,0feh,0fdh,0fdh,0fch,0fbh,0fah,0fah,0f9h,0f8h,0f6h
DB0f5h,0f4h,0f3h,0f1h,0f0h,0efh,0edh,0ebh,0eah,0e8h,0e6h,0e4h,0e2h,0e0h,0deh,0dch
DB0dah,0d8h,0d5h,0d3h,0d1h,0ceh,0cch,0c9h,0c7h,0c4h,0c1h,0bfh,0bch,0b9h,0b6h,0b3h
DB0b1h,0aeh,0abh,0a8h,0a5h,0a2h,09fh,09ch,099h,096h,093h,090h,08ch,089h,086h,083h
DB080h,07dh,07ah,077h,074h,070h,06dh,06ah,067h,064h,061h,05eh,05bh,058h,055h,052h
DB04fh,04dh,04ah,047h,044h,041h,03fh,03ch,039h,037h,034h,032h,02fh,02dh,02bh,028h
DB026h,024h,022h,020h,01eh,01ch,01ah,018h,016h,015h,013h,011h,010h,00fh,00dh,00ch
DB00bh,00ah,008h,007h,006h,006h,005h,004h,003h,003h,002h,002h,002h,001h,001h,000h
DB000h,000h,001h,001h,002h,002h,002h,003h,003h,004h,005h,006h,006h,007h,008h,00ah
DB00bh,00ch,00dh,00fh,010h,011h,013h,015h,016h,018h,01ah,01ch,01eh,020h,022h,024h
DB026h,028h,02bh,02dh,02fh,032h,034h,037h,039h,03ch,03fh,041h,044h,047h,04ah,04dh
DB04fh,052h,055h,058h,05bh,05eh,061h,064h,067h,06ah,06dh,070h,074h,077h,07ah,07dh
END
中断版调频――方波
CCCDATA30H
ORG0000H
LJMPSTART
ORG0003H;外部中断0
LJMPMAIN
ORG0060H
START:
MOVSP,#70H;更改堆栈指针,避免堆栈与工作寄存器区发生冲突
MOVCCC,#08H
MAIN:
SETBIT0;外部中断请求0为下降沿触发方式
SETBEA;中断允许总开关打开
SETBEX0;允许外部中断0中断
JNBP1.5,JIA
JNBP1.6,JIAN
JNBP1.3,IR3;如果K3键闭合,则跳转至IR3输出方波
LJMPMAIN
JIA:
LCALLWSC
LCALLWSC
LCALLWSC
MOVA,CCC
CJNEA,0FBH,INC1
LJMPMAIN
INC1:
INCCCC
LJMPMAIN
JIAN:
LCALLWSC
LCALLWSC
LCALLWSC
MOVA,CCC
CJNEA,#00H,DEC1
LJMPMAIN
DEC1:
DECCCC
LJMPMAIN
DELAY:
MOVR7,CCC;延时子程序
DELAY1:
MOVR5,#0FFH
DELAY2:
DJNZR5,DELAY2
DJNZR7,DELAY1
RET
WSC:
MOVR7,#30H;延时子程序
WSC1:
MOVR5,#0FFH
WSC2:
DJNZR5,WSC2
DJNZR7,WSC1
RET
IR3:
MOVR0,#0FEH;设置端口地址
POSI:
MOVA,#00H;给A赋值0x00
MOVX@R0,A;写入
LCALLDELAY;延时
JBP1.3,MAIN;如果k3键已经断开,则返回
NEGA:
MOVA,#0FEH;给A赋值0xFF
MOVX@R0,A;写入
LCALLDELAY
JBP1.3,MAIN;如果k3键已经断开,则返回
SJMPPOSI;跳转至POSI,继续下一个波形的输出
LJMPMAIN;返回
END
中断版调频――梯形波
CCCDATA30H
ORG0000H
LJMPSTART
ORG0003H;外部中断0
LJMPMAIN
ORG0060H
START:
MOVSP,#70H;更改堆栈指针,避免堆栈与工作寄存器区发生冲突
MOVCCC,#08H
MAIN:
SETBIT0;外部中断请求0为下降沿触发方式
SETBEA;中断允许总开关打开
SETBEX0;允许外部中断0中断
JNBP1.5,JIA
JNBP1.6,JIAN
JNBP1.3,IR1;如果K1键闭合,则跳转至IR1输出梯形波
LJMPMAIN
JIA:
LCALLWSC
LCALLWSC
LCALLWSC
MOVA,CCC
CJNEA,#0FFH,INC1
LJMPMAIN
INC1:
INCCCC
LJMPMAIN
JIAN:
LCALLWSC
LCALLWSC
LCALLWSC
MOVA,CCC
CJNEA,#00H,DEC1
LJMPMAIN
DEC1:
LCALLWSC
DECCCC
DECCCC
LJMPMAIN
YANSHI:
MOVR7,CCC;延时子程序
YANSHI2:
DJNZR7,YANSHI2
NOP
MOVR7,CCC
NOP
YANSHI3:
DJNZR7,YANSHI3
RET
IR1:
MOVR0,#0FEH;设置端口地址
MOVA,#00H
UP:
MOVX@R0,A;写入
LCALLYANSHI
JBP1.3,MAIN;如果k1键已经断开,则返回
INCA;A加一
JNZUP;循环
DECA;如果已经溢出,则减一,减一之后A的值为255
LCALLWSC;延时
JBP1.3,MAIN;如果k1键已经断开,则返回
DOWN:
DECA
MOVX@R0,A;写入
JBP1.3,MAIN;如果k1键已经断开,则返回
LCALLYANSHI
JNZDOWN;循环
SJMPUP;如果减到0,则跳转至UP,继续执行加一操作
LJMPMAIN;返回
WSC:
MOVR7,#8EH;延时子程序
WSC1:
MOVR5,#5FH
WSC2:
DJNZR5,WSC2
DJNZR7,WSC1
RET
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 单片机 波形 发生器 调频 可调 频率 汇编