资源描述:
《电子秒表课程设计.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、电子秒表设计一个可任意启动/停止的电子秒表,要求用6位LED数码显示,计时单位为1/100秒。利用功能键进行启/停控制。其功能为:上电后计时器清0,当第一次(或奇数次)按下启/停键时开始计数。第2次(或偶数次)按下该键时停止计时,再一次按启/停键时清零后重新开始计时。可用开关控制,也可用按键控制。(开关控制☆)(按键控制★)一系统连线图14二设计程序P8255_AEQU200HP8255_BEQU202HP8255_CEQU204HP8255_CTEQU206HP8253_0EQU400HP8253_1EQ
2、U402HP8253_2EQU404HP8253_CTEQU406HCODESEGMENT'CODE';L10ASSUMECS:CODE,DS:DATA,SS:STACKmainprocSTART:MOVAX,DATAMOVDS,AXMOVAX,0MOVES,AXMOVBX,02H*4LEAAX,INT014MOVES:[BX],AXMOVAX,SEGINT0MOVES:[BX+2],AxMOVAL,81HMOVDX,P8255_CTOUTDX,AL;8255A初始化MOVAL,36HMOVDX,P8253
3、_CTOUTDX,AL;定时器0初始化,方式3MOVAX,1000MOVDX,P8253_0OUTDX,ALMOVAL,AHMOVDX,P8253_0OUTDX,AL;8253初始化完毕next15:movs1,0movs2,0movm1,0movm2,014movh1,0movh2,0MOVCX,06HMOVbp,0LEASI,S1LEDDISP3:MOVAX,BPLEABX,LEDWEXLATMOVDX,P8255_BOUTDX,ALMOVAL,[SI];输出位码LEABX,LEDTABXLAT14cm
4、pcx,4jnznext14oral,80hnext14:MOVDX,P8255_AOUTDX,ALINCSIINCbpCALLDELAY_1MS1;输出段码LOOPLEDDISP3movdx,p8255_cinal,dxANDAL,1;109Jnznext15W3:MOVDX,P8255_CINAL,DXANDAL,01H14JZW3;循环直到按键松开LOP1:CALLDISPJMPLOP1RETMAINENDPDISPPROC;输出子程序MOVCX,06HMOVbp,0LEASI,S1LEDDISP:M
5、OVAX,BPLEABX,LEDWEXLAT14MOVDX,P8255_BOUTDX,ALMOVAL,[SI];输出位码LEABX,LEDTABXLATcmpcx,4jnznext11oral,80hnext11:MOVDX,P8255_AOUTDX,ALINCSIINCbpCALLDELAY_1MS;输出段码LOOPLEDDISPRETDISPENDPDELAY_1MSPROC;1ms延时子程序pushcxMOVCX,500CALLKEY14LOOP$popcxRETDELAY_1MSENDPDELAY_
6、1MS1PROC;1ms延时子程序pushcxMOVCX,500LOOP$popcxRETDELAY_1MS1ENDPKEYPROCMOVDX,P8255_CINAL,DXANDAL,01Hjnzexit114W1:MOVBL,S1MOVTEMP_1,BLMOVBL,S2MOVTEMP_2,BLMOVBL,M1MOVTEMP_3,BLMOVBL,M2MOVTEMP_4,BLMOVAL,H1MOVTEMP_5,BLMOVBL,H2MOVTEMP_6,BLMOVDX,P8255_CINAL,DXANDAL,01
7、HJZW1;循环直到按键松开14next12:MOVCX,06HMOVbp,0LEASI,TEMP_1LEDDISP1:MOVAX,BPLEABX,LEDWEXLATMOVDX,P8255_BOUTDX,ALMOVAL,[SI];输出位码14LEABX,LEDTABXLATcmpcx,4jnznext13oral,80hnext13:MOVDX,P8255_AOUTDX,ALINCSIINCbpCALLDELAY_1MS1;输出段码LOOPLEDDISP1movdx,p8255_cinal,dxANDAL,
8、1;109Jnznext12W2:MOVDX,P8255_CINAL,DX14ANDAL,01Hmovs1,0movs2,0movm1,0movm2,0movh1,0movh2,0JZW2;循环直到按键松开EXIT1:RETKEYENDPINT0PROCFARINCS1CMPS1,10JNZEXITMOVS1,014INCS2CMPS2,10JNZEXITMOVS2,0INCM1CMPM1,10JNZEXITMO