实验名称基于8255的LED显示函数信号发生器设计课题内容和要求基本要求Word下载.docx
《实验名称基于8255的LED显示函数信号发生器设计课题内容和要求基本要求Word下载.docx》由会员分享,可在线阅读,更多相关《实验名称基于8255的LED显示函数信号发生器设计课题内容和要求基本要求Word下载.docx(22页珍藏版)》请在冰豆网上搜索。
SCAN:
MOVDPTR,#1FFCH;
PA口地址
MOVA,#00H
MOVX@DPTR,A;
PA0~PA3输出低电平
INCDPTR;
DPTR指向PC口
INCDPTR
MOVXA,@DPTR;
读PC口的值
ANLA,#0FH;
屏蔽无用位
CJNEA,#0FH,DETAIL;
判断是否有低电平
ACALLDELAY1;
延时
ACALLDELAY1
AJMPSCAN;
无键按下则继续扫描
DETAIL:
ACALLDELAY1;
消抖动
MOVDPTR,#1FFCH;
再判断是否有键按下
MOVX@DPTR,A
MOVXA,@DPTR
ANLA,#0FH
CJNEA,#0FH,CONTINUE;
有键按下则做进一步的判断
无键按下继续扫描
CONTINUE:
CLREA;
有键按下驱动蜂鸣器
SETBP1.7
ACALLDELAY2
CLRP1.7
SETBEA
MOVR4,#02H;
扫描行数送入R4中
MOVA,#0FEH
LINE:
MOVDPTR,#1FFCH
MOVR2,A;
行号送R2
置PA0为低电平
CJNEA,#0FH,FIND;
判断第一行是否有键按下
MOVA,R2
RLA
DJNZR4,LINE
SJMPSCAN;
FIND:
MOVR3,A列号存入R3中
CJNEA,#0FEH,LINE2;
判断是否是第一行有键按下
LINE1:
MOVA,R3;
第一行有键按下
CJNEA,#0EH,L1R2;
判断是哪个按键按下
L1R1:
MOVR0,#01H;
有波形键按下键按下
MOVR1,#01H;
波形标志1
MOVR7,#00H
CLRTR1
CLRTR0
SETBTR0
SJMPSCAN
L1R2:
CJNEA,#0DH,L1R3
MOVR0,#01H;
MOVR1,#02H;
方波标志
SETBTR1
L1R3:
MOVR1,#03H;
三角波标志
AJMPSCAN
LINE2:
第二行有键按下
CJNEA,#0EH,L2R2
L2R1:
CJNER0,#01H,NONE1;
有波形时才能进行频率增减操作
CJNER6,#00H,START1;
没有减到最小频率值时继续减否则减频操作失败
AJMPNONE1
START1:
DECR6;
减频
MOVA,R6
MOVDPTR,#TABLE3
MOVCA,@A+DPTR
MOVTH0,A;
重置计数初值
NONE1:
AJMPDISPLAY
L2R2:
CJNEA,#0DH,L2R3
CJNER0,#01H,NONE2;
CJNER6,#0EH,START2;
没有增到最大频率值时继续增否则增频操作失败
AJMPNONE2
START2:
INCR6;
增频
NONE2:
L2R3:
CJNEA,#0BH,L2R4;
显示波形周期值
MOVF,#01H
AJMPDISPLAY
L2R4:
MOVF,#00H;
显示波形频率值
2.显示部分
显示部分硬件图:
开发板上设置了6位8段数码管,采用动态扫描方式连接,各位数码管的A~DP互联后经拨码开关S1后由P0口控制,数码管的COM分别经拨码开关S2后由P10~P15控制。
当某一数码管COM口控制端为低电平时,三极管导通,该位数码管选中,此时可通过P0口发送待显示数据的编码。
显示部分流程图:
显示部分程序:
DISPLAY:
MOVA,F
CJNEA,#01H,FREQ;
判断F的值
AJMPTIME
FREQ:
CLREA;
显示频率值
MOVDPTR,#TAB1
MOVP1,#07EH
MOVP0,A
MOVDPTR,#TAB2
MOVP1,#07DH
MOVDPTR,#TAB3
MOVP1,#07BH
MOVDPTR,#TAB4
MOVP1,#077H
MOVA,T
DECA
MOVT,A
JNZDISPLAY
TIME:
显示周期值
MOVDPTR,#TAB5
MOVDPTR,#TAB6
MOVDPTR,#TAB7
MOVDPTR,#TAB8
3.波形产生部分
正弦波和三角波采用查表的方式来获得,每个完整周期有32个抽样值,采用T0中断方式将32个抽样值在所需的时间内显示出来。
方波采用算法输出,周期为T,采用T1中断没T/2中断一次输出高电平或低电平,每中断一次电平颠倒一次。
四、硬件电路图
五、源程序代码
KEQU30H;
存方波电平
TEQU32H;
显示扫描遍数
FEQU34H;
显示周期或频率标志
ORG0000H
AJMPMAIN
ORG000BH
LJMPTIME0
ORG001BH
LJMPTIME1
ORG0040H
MAIN:
MOVTMOD,#12H;
T0方式2,T1方式1
MOVTH0,#0FBH;
赋计数初值
MOVTL0,#0FBH
MOVTH1,#0FEH
MOVTL1,#2CH
MOVIE,#8AH;
CPU开中断,定时器中断开
MOVDPTR,#1FFFH;
写8255控制字
MOVA,#89H;
PA口输出,PC口输入
MOVR0,#00H
MOVR6,#09H
MOVT,#0FFH
MOVK,#0FFH
MOVF,#00H
MOVDPTR,#1FFFH
CJNEA,#89H,FZ
AJMPZC
FZ:
MOVA,#89H
ZC:
DELAY1:
MOVR4,#10;
延时子程序
AA1:
MOVR5,#250
AA:
DJNZR5,AA
DJNZR4,AA1
RET
DELAY2:
MOVR4,#30;
BB1:
BB:
DJNZR5,BB
DJNZR4,BB1
ORG0200H
TIME0:
PUSHACC;
2
PUSHDPH;
PUSHDPL;
MOVP1,#07FH;
1
CJNER1,#01H,KEY3;
KEY1:
MOVDPTR,#TABLE4;
MOVA,R7;
MOVCA,@A+DPTR;
MOVDPTR,#3FFFH;
INCR7;
AJMPRETURN;
KEY3:
MOVDPTR,#TABLE5;
RETURN:
POPDPL;
POPDPH;
POPACC;
RETI;
ORG0300H
TIME1:
MOVA,R6;
MOVDPTR,#TABLE1;
MOVTH1,A;
MOVDPTR,#TABLE2;
MOVTL1,A;
KEY2:
MOVA,K;
CPLA;
MOVK,A;
POPDPL;
TAB1:
DB0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0C0H;
LED
DB0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0C0H
TAB2:
DB0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0C0H
TAB3:
DB0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H
DB98H,0C0H,0F9H,0A4H,0B0H,99H,92H
TAB4:
DB0C0H,0F9H,0F9H,0F9H,0F9H,0F9H,0F9H
TAB5:
DB0C0H,0C0H,0B0H,0C0H,0C0H,0F8H,0B0H,92H
DB0F9H,0C0H,0F9H,0B0H,0F8H,0F9H,0F8H
TAB6:
DB0C0H,0C0H,0B0H,92H,0C0H,82H,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