您好,欢迎访问三七文档
南通大学实验报告簿姓名学号学院班级实验课程名称—学年第学期13.2电子秒表13.2.1功能说明本例综合使用8255A和定时器,实现了电子秒表的计时、暂停和清零功能。该电路用到的主要仿真原件清单:QTYPART-REFSVALUECODE---------------------Resistors---------2R1,R2PULLUPIntegratedCircuits-------------------3U1,U2,U4742731U3NOT1U580861U6741541U78255A1U8OR_41U98253A1U10OR_32U11,U14OR_51U1274LS2451U13OR1U15NAND_313.2.2Proteus电路设计本例实现了电子秒表的计时、暂停和清零功能。计时功能由定时器8253控制实现。13.2.3代码设计本例利用8253实现定时,利用NMI中断,实现了暂停和清零功能,程序代码如下:a1equ0000hb1equ0002hc1equ0004hctr1equ0006h;8255各端口地址a2equ0200h;8253计数器0端口地址ctr2equ0206h;8253控制端口地址a3equ0100hdatasegment;keynumdb0EEH,0DEH,0BEH,7EH,0EDH,0DDH,0BDH,7DH,0EBH,0DBH,0BBH,7BH,0E7H,0D7H,0B7H,77Htabdb3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,77H,7CH,39H,5EH,79H,71Hbufdb0,0,0,0buf1db0,0,0,0,0,0,0,0buf2db0,0;前为第一开关次数buf3db80dup(?)dataendscodesegment'code'assumeds:data,cs:codestart:movax,datamovds,ax;设中段入口地址设置movax,0moves,axmovdi,08movax,offsetintr_keycldstoswmovax,segintr_keystoswmovax,datamoves,ax;8255写入控制字moval,10001001b;A口B口输出显示,C口高四位低四位输入movdx,ctr1outdx,aln3:calljishujmpn3n2:leasi,buf2movbh,00hmovbl,1h[si]leadi,buf3adddi,bxaddbl,8mov1h[si],blleasi,buf1cldmovcx,8repmovsbn4:calldisjmpn4n5:leasi,buf2movbh,00hmovbl,1h[si]cmpbl,0jzn1leadi,buf1subbl,8mov1h[si],blleasi,buf3addsi,bxcldmovcx,8repmovsbn6:calldisjmpn6n1:callqinlinjmpn1;jmpstartjishuprocnear;计数子程序leasi,bufmovbl,[si]cmpbl,100jnzs6s1:movbl,0mov[si],blmovah,1h[si]cmpah,59jzs2incahmov1h[si],ahjmps6s2:movah,0mov1h[si],ahmovah,2h[si]cmpah,59jzS4incahmov2h[si],ahjmps6s4:movah,0mov2h[si],ahmovah,3h[si]cmpah,23jzs6incahmov3h[si],ahs6:callchumovcx,3s5:calldisloops5calldelay1sincbyteptr[si]retjishuendpchuproc;rukoual;数处理子程序pushsipushbxmovbl,4leadi,buf1leasi,bufnext:lodsbmovah,00movcl,10divclxchgah,alstosbmoval,ahstosbdecbljnznextpopbxpopsiretchuendpdisprocnear;显示buf1中的值pushbxpushcxleabx,tableadi,buf1movcx,8movah,7Fhloop1:moval,[di]xlat;换码movdx,a1outdx,almovdx,b1moval,ahoutdx,almovbh,1calldelaycallqpleabx,tabrorah,1incdilooploop1popcxpopbxretdisendpdelay1sprocnear;8253延时子程序pushdxpushaxmovdx,ctr2;8253kongzimoval,00110000boutdx,al;8253计数器0控制字方式0out端作为中断请求信号movdx,a2moval,01houtdx,almoval,00houtdx,almovdx,a3M1:inal,dxtestal,01hjzM1popaxpopdxretdelay1sendpqpprocnear;清频子程序moval,0ffhmovdx,b1outdx,alretqpendpdelayPROCNEAR;内部延时之程序PUSHbxPUSHCXwait0:MOVCX,06hwait1:LOOPwait1DECbhJNZwait0POPCXPOPbxRETdelayENDPintr_keyprocnear;中断服务子程序callkeytestal,2hjzn1testal,4hjzn5leadi,buf2movbh,[di]incbhmov[di],bhtestbh,1hjnzn2jmpn3iretintr_keyendpqinlinproc;键盘清零子程序movax,0leadi,bufmovcx,14cldrepstosbcalldisqinlinendpkeyproc;读取键盘程序movdx,c1inal,dxretkeyendpcodeendsendstart13.2.4仿真分析与思考本实例电路的仿真运行结果AD0AD1AD2AD3AD4AD5AD6AD7AD8AD9AD10AD11AD12AD13AD14AD15A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15AD16AD17AD18AD19A19A18A17A16A9A10A11A8A12A13A14A15A3A4A5A6A7AD4AD5AD6AD7AD0AD0AD1AD3AD2AD0AD1AD2AD3AD4AD5AD6AD7AD0AD1AD2AD3AD4AD5AD6AD7D03D14D27D38D413D514D617D718CLK11MR1Q02Q15Q26Q39Q412Q515Q616Q719U174273D03D14D27D38D413D514D617D718CLK11MR1Q02Q15Q26Q39Q412Q515Q616Q719U274273U3NOTAD[0..15]A[0..19]AD[16..19]AD[16..19]D03D14D27D38D413D514D617D718CLK11MR1Q02Q15Q26Q39Q412Q515Q616Q719U474273BHEAD[0..15]READY22INTR18NMI17RESET21CLK19MN/MX33HOLD/GT131HLDA/GT030A[16..19]M/IO/S028ALE/QS025DT/R/S127INTA/QS124TEST23BHE34DEN/S226RD32WR/LOCK29U58086PROGRAM=dianzimiaobiao.EXELOAD_SEG=0x0800SRCFILE=miaobiao4.asmA23B22C21D20E118E219011223344556677889910101111131214131514161517U674154IO0IO1IO2IO3IO4IO5IO6IO7IO8IO9IO10IO11IO12IO13IO14IO15M/IOWRRDU8OR_4U11OR_5D034D133D232D331D430D529D628D727RD5WR36A09A18RESET35CS6PA04PA13PA22PA31PA440PA539PA638PA737PB018PB119PB220PB321PB422PB523PB624PB725PC014PC115PC216PC317PC413PC512PC611PC710U78255AGND=VSSVCC=VDDAD[0..7]RDWRA1A2IO0A0U10OR_3M/IOD08D17D26D35D44D53D62D71RD22WR23A019A120CS21CLK09GATE011OUT010CLK115GATE114OUT113CLK218GATE216OUT217U98253AA02B018A13B117A24B216A35B315A46B414A57B513A68B612A79B711CE19AB/BA1U1274LS245U9(CLK0)AD[0..7]AD[0..7]RDWRA1A2IO2A0A0IO1M/IOU14OR_5A1A2123U13ORR1PULLUPR2PULLUPU15NAND_3ZDZD.....暂停、复位清零说明:清零后键盘需按两下才能继续,而暂停后只要按一下就可复位
本文标题:实验报告2
链接地址:https://www.777doc.com/doc-5627300 .html