您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 能源与动力工程 > 华北电力大学-接口实验参考程序
4.38259A中断控制实验表1中断类型码及中断向量地址主片中断类型码和中断向量地址中断序号IR0IR1IR2IR3IR4IR5IR6(MIR6)IR7(MIR7)中断类型码08H09H0AH0BH0CH0DH0EH0FH矢量地址0020H~0023H0024H~0027H0028H~002BH002CH~002FH0030H~0033H0034H~0037H0038H~003BH003CH~003FH说明未开放未开放未开放未开放串口未开放可用可用从片中断类型码和中断向量地址中断序号IR0IR1(SIR1)IR2IR3IR4IR5IR6IR7中断类型码30H31H32H33H34H35H36H37H矢量地址00C0H~00C3H00C4H~00C7H00C8H~00CBH00CCH~00CFH00C0H~00C3H00C4H~00C7H00C8H~00CBH00CCH~00CFH说明开放4.3.31.8259单次实验(1)实验步骤:1)按图4-17所示连接实验线路2)编写实验程序,经编译、链接无误后装入系统。3)运行程序,重复按单次脉冲开关KK1+,记录实验结果或看到的现象。(2)实验参考程序清单:SSTACKSEGMENTSTACKDW32DUP(?)SSTACKENDSCODESEGMENTASSUMECS:CODESTART:CLIPUSHDSMOVAX,0000HMOVDS,AXMOVAX,OFFSETMIR7;取中断入口地址MOVSI,003CH;中断矢量地址MOV[SI],AX;填IRQ7的偏移矢量MOVAX,SEGMIR7;段地址MOVSI,003EHPOPDS;初始化主片8259MOVAL,11HOUT20H,AL;ICW1MOVAL,08HOUT21H,AL;ICW2MOVAL,04HOUT21H,AL;ICW3系统总线单次脉冲单元MIR7KK1+主8259MOVAL,01HOUT21H,AL;ICW4MOVAL,7FHOUT21H,AL;主8259OCW1STIAA1:NOPJMPAA1MIR7:CALLDELAYMOVAX,0137HINT10H;显示字符7MOVAX,0120HINT10HMOVAL,20HOUT20H,AL;中断结束命令IRETDELAY:PUSHCXMOVCX,0F00HAA0:PUSHAXPOPAXLOOPAA0POPCXRETCODEENDSENDSTART4)改变接线方式,将KK1+接入MIR6,修改程序,重复按单次脉冲开关KK1+,使显示屏显示字符”6”。记录实验结果或看到的现象。SSTACKSEGMENTSTACKDW32DUP(?)SSTACKENDSCODESEGMENTASSUMECS:CODESTART:CLIPUSHDSMOVAX,0000HMOVDS,AXMOVAX,OFFSETMIR6;取中断入口地址MOVSI,0038H;中断矢量地址MOV[SI],AX;填IRQ7的偏移矢量MOVAX,SEGMIR6;段地址MOVSI,003AHPOPDS;初始化主片8259MOVAL,11HOUT20H,AL;ICW1MOVAL,08HOUT21H,AL;ICW2MOVAL,04HOUT21H,AL;ICW3MOVAL,01HOUT21H,AL;ICW4MOVAL,0BFHOUT21H,AL;主8259OCW1STIAA1:NOPJMPAA1MIR6:CALLDELAYMOVAX,0136HINT10H;显示字符7MOVAX,0120HINT10HMOVAL,20HOUT20H,AL;中断结束命令IRETDELAY:PUSHCXMOVCX,0F00HAA0:PUSHAXPOPAXLOOPAA0POPCXRETCODEENDSENDSTART思考题:分析中断响应过程,主程序如何调用中断服务程序的2.8259级联实验1)按图4-17所示连接实验线路2)编写实验程序,经编译、链接无误后装入系统。3)运行程序,重复按单次脉冲开关KK1+,记录实验结果或看到的现象。4)实验参考程序清单:SSTACKSEGMENTSTACKDW32DUP(?)SSTACKENDSCODESEGMENTASSUMECS:CODESTART:PUSHDSMOVAX,0000HMOVDS,AXMOVAX,OFFSETMIR7;取中断入口地址MOVSI,003CH;中断矢量地址MOV[SI],AX;填IRQ7的偏移矢量MOVAX,SEGMIR7;段地址MOVSI,003EHMOV[SI],AX;填IRQ7的段地址矢量MOVAX,OFFSETSIR1MOVSI,00C4HMOV[SI],AXMOVAX,SEGSIR1MOVSI,00C6HMOV[SI],AXCLIPOPDS;初始化主片8259MOVAL,11HOUT20H,AL;ICW1MOVAL,08HOUT21H,AL;ICW2MOVAL,04HOUT21H,AL;ICW3MOVAL,01HOUT21H,AL;ICW4;初始化从片8259MOVAL,11HOUT0A0H,AL;ICW1MOVAL,30HOUT0A1H,AL;ICW2MOVAL,02HOUT0A1H,AL;ICW3MOVAL,01HOUT0A1H,AL;ICW4MOVAL,0FDHOUT0A1H,AL;OCW1=11111101MOVAL,6BHOUT21H,AL;主8259OCW1STI系统总线单次脉冲单元MIR7KK1+主8259SIR1从8259KK2+AA1:NOPJMPAA1MIR7:CALLDELAYMOVAX,014DHINT10H;MMOVAX,0137HINT10H;显示字符7MOVAX,0120HINT10HMOVAL,20HOUT20H,AL;中断结束命令IRETSIR1:CALLDELAYMOVAX,0153HINT10H;SMOVAX,0131HINT10H;显示字符1MOVAX,0120HINT10HMOVAL,20HOUT0A0H,ALOUT20H,ALIRETDELAY:PUSHCXMOVCX,0F00HAA0:PUSHAXPOPAXLOOPAA0POPCXRETCODEENDSENDSTART实验现象分析:M7S1:MIR7中断请求先到S1M7:SIR1中断请求先送到或MIR7与SIR1中断请求信号同时到,但SIR1优先级高,先响应SIR1中断请求MS17:M7S1:MIR7中断请求先到,但未执行完时,SIR1中断请求送到,其优先级高,打断MIR7中断服务程序3.8259综合实验SSTACKSEGMENTSTACKDW32DUP(?)SSTACKENDSCODESEGMENTASSUMECS:CODESTART:CLIPUSHDSMOVAX,0000HMOVDS,AXMOVAX,OFFSETMIR7;取中断入口地址MOVSI,003CH;中断矢量地址MOV[SI],AX;填IRQ7的偏移矢量MOVAX,SEGMIR7;段地址MOVSI,003EHPOPDS;初始化主片8259MOVAL,11HOUT20H,AL;ICW1MOVAL,08HOUT21H,AL;ICW2MOVAL,04HOUT21H,AL;ICW3MOVAL,01HOUT21H,AL;ICW4MOVAL,7FHOUT21H,AL;主8259OCW1STIMOVSI,10AA1:MOVCX,10;显示字符个数10送入CXMOVBL,30H;显示字符‘0’,填入字符0的编码MOVAH,01H;显示一个字符A1:MOVAL,BLINT10HINCBL;显示下一个字符PUSHCXMOVCX,0FFFFHA2:LOOPA2;延时POPCXDECCXJNZA1JMPAA1;循环显示0~9MIR7:CALLDELAYMOVAX,014FHINT10H;显示字符OMOVAX,014BHINT10H;显示字符KMOVAL,20HOUT20H,AL;中断结束命令DECSIJNZAA2CLIMOVAL,0FFHOUT21H,ALAA2:IRETDELAY:PUSHCXMOVCX,0F00HAA0:PUSHAXPOPAXLOOPAA0POPCXRETCODEENDSENDSTART4.48254定时/计数器应用实验1.计数应用实验编写程序,用开关模拟事件,用8254的计数功能进行计数。将8254的计数器0设置为方式0,计数初值为十进制数3,单次脉冲KK1+接入CLK0作为输入,OUT0连接MIR7,每当KK1+按动4次后产生中断请求,在屏幕上显示一个字符“M”。实验步骤:(1)实验接线如图4-21所示;(2)编写实验程序,经编译、链接无误后装入系统;(3)运行程序,按动KK1+产生单次脉冲,观察实验现象;(4)改变计数值,验证8254的计数功能。D0D7...WRRDCSXD0XD7...IOW#IOR#IOY3系统总线8254单元A0A1XA1XA2单次脉冲单元MIR7GATE0CLK0OUT0VCCKK1+4.7K2.修改内容1—计数应用实验程序,完成按动开关3次后产生中断,屏幕显示“M”。3.修改内容1—计数应用实验程序,要求屏幕显示第几次中断中断?参考程序:A8254EQU06C0HB8254EQU06C2HC8254EQU06C4HCON8254EQU06C6HSSTACKSEGMENTSTACKDW32DUP(?)SSTACKENDSCODESEGMENTASSUMECS:CODE,SS:SSTACKSTART:PUSHDSMOVAX,0000HMOVDS,AXMOVAX,OFFSETIRQ7;取中断入口地址MOVSI,003CH;中断矢量地址MOV[SI],AX;填IRQ7的偏移矢量MOVAX,CS;段地址MOVSI,003EHMOV[SI],AX;填IRQ7的段地址矢量CLIPOPDS;初始化主片8259MOVAL,11HOUT20H,AL;ICW1MOVAL,08HOUT21H,AL;ICW2MOVAL,04HOUT21H,AL;ICW3MOVAL,01HOUT21H,AL;ICW4MOVAL,6FH;OCW1OUT21H,AL;8254MOVDX,CON8254MOVAL,10H;计数器0,方式0OUTDX,ALMOVDX,A8254MOVAL,04HOUTDX,ALSTIAA1:JMPAA1IRQ7:MOVDX,A8254MOVAL,04HOUTDX,ALMOVAX,014DHINT10H;显示字符MMOVAX,0120HINT10HMOVAL,20HOUT20H,AL;中断结束命令IRETCODEENDSENDSTART2定时应用实验1)编写程序,应用8254的定时功能,将8254的计数器0设置为方式3,用信号源1MHz作为CLK0时钟,OUT0输出周期为60ms的方波接到发光二极管上,运行程序,观察发光二极管状态。(时钟源和GATE信号实验箱内部已经接好线)发光二极管点亮实验程序清单A8254EQU06C0HB8254EQU06C2HC8254EQU06C4HCON8254EQU06C6HSSTACKSEGMENTSTACKDW32DUP(?)SSTACKENDSCODESEGMENTASSUMECS:CODESTART:MOVDX,CON8254;8254MOVAL,36H;计数器0,方式3OUTDX,ALMOVDX,A8254MOVAL,0E8HOUTDX,ALMOVAL,03HOUTDX,ALAA1:JMPAA1CODEENDSENDSTART1)编写程序,应用8254的定时功能,实现一个秒表计时并在屏幕上显示。(时钟源和GATE信号实验箱内部已经接好线)A8254EQU06C0HB8254EQU06C2HC8254EQU06C4HCON8254EQU06C6HSSTACKSEGMENTSTACKDW32DUP(?)SSTACKENDSCODESEGMENTASSUMECS:CODESTART:CLIPUSHDSMOVAX,0000HMOVDS,AXMOVAX,OFF
本文标题:华北电力大学-接口实验参考程序
链接地址:https://www.777doc.com/doc-5860299 .html