还剩25页未读,继续阅读
本资源只提供10页预览,全部文档请下载后查看!喜欢就下载吧,查找使用更方便
文本内容:
微机原理与接口技术实验报告学号4091030姓名:贤会利提交日期成绩:东北大学秦皇岛分校实验1可编程定时器/计时器8253定时器
一、实验目的掌握8253的基本工作原理和编程方法
二、实验内容按图16虚线连接电路,将计数器0设置为方式0,计数器初值为NNWOFH,用手动逐个输入单脉冲,编程使计数值在屏幕上显示,并同时用逻辑笔观察OUTO电平变化当输入N+1个脉冲后OUTO变高电平
三、编程提示8253控制寄存器地址283H计数器0地址280H计数器1地址281Hjle findtpcl_disp_num;若是则为O-9,ASCH码加30Hadd dl,7;否则为‘A-F,ASCII码加37Hf indtpcl_di spnum:add dl,30hmov ah,02h;显示int21hpop expop axloop findtpcl_disp_loopl popbx popex popdxret;子程序返回findtpcl_disp endpcodeendsend start计数器
一、实验目的掌握8253的基本工作原理和编程方法
二、实验内容按图17连接电路,将计数器
0、计数器1分别设置为方式3,计数初值设为1000,用逻辑笔观察OUT1输出电平的变化(频率1HZ)
三、编程提示18253控制寄存器地址283H.计数器0地址280H计数器1地址281HCLKO连接时钟1MHZ四.实验原理图五,实验流程图六.实验原代码;*8253分频*io8253a equ280h-0280hio8253b equ281h-0280hio8253c equ283h-0280hio_port_addre equ0cf8h;32位配置地址端口io_port_dataequ Ocfch;32位配置数据端口io_plx_idequ0540610b5h;TPC卡设备与厂商IDdata segmentio_9054base_addressdb4DUP0;TPC卡9054芯片I/O基地址暂存空间io_base_addressdb4DUP0;TPC卡I/O基地址暂存空间memory_base_addressdb4DUP0;TPC卡MEMORY基地址暂存空间interruptlinedb2DUP0;TPC卡中断号暂存空间pcicardnotfinddb Odh,Oah,TPC pci card notfind oraddress/interrupt error!!!’,Odh,Oah,‘$‘io9054baseaddressiobaseaddress db Odh,Oah,TPC pci card9054Chip1/0Base Address:,db Odh,Oah,5TPC pcicard I/O Base Address:,‘memorybaseaddress dbOdh,Oah,J TPC pcicard Memory BaseAddress:intnumberdb Odh,Oah,J TPC pcicard Interrupt Line:,‘enter_returndb Odh,Oah/$data endsstackssegmentdb100dupstacks ends codesegmentassume cs:code,ds:data,SS:STACKS,es:data.386start:mov ax,datamov ds,axmov es,axmov ax,stacksmov ss,axcall findtpcl;查找TPC卡资源并显示mov dx,word ptriobaseaddressadd dx,io8253c;向8253写控制字mov al,36h;使0通道为工作方式3out dx,almov ax,1000;写入循环计数初值1000mov dx,word ptr io base addressadd dx,io8253aout dx,al;先写入低字节mov al,ahout dx,al;后写入高字节mov dx,word ptr io_base_addressadd dx,io8253cmov al,76h;设8253通道1工作方式2out dx,almov dx,word ptr io_base_addressadd dx,io8253bout dx,al;先写低字节mov al,ah;后写高字节out dx,al;程序退出mov ah,4chint21hmov ax,1000;写入循环计数初值1000findtpcl proc near;查找TPC卡资源并显示pushadpushfdmov ebx,080000000hfindtpcl_next:add ebx,lOOhcmp ebx,081000000h jnzfindtpcl_continuemov dx,offset pcicardnotfind;显示未找至Utpc卡提示信息mov ah,09hint21hmov ah,4chint21h;退出findtpcl_continue:mov dx,io_port_addremov eax,ebxout dx,eax;写地址口mov dx,io_port_datain eax,dx;读数据口cmp eax,io_plx_idjnz findtpcl_next;检查是否发现tpc卡mov dx,io_port_addremov eax,ebxadd eax,14hout dx,eax;写地址口mov dx,io_port_datain eax,dx;读数据口mov dword ptr io_9054base_address,eaxand eax,1jz findtpcl_next;检查是否为i/o基址信息mov eax,dword ptr io_9054base_addressand eax,Offfffffehmov dword ptr io_9054base_address,eax;去除i/o指示位并保存mov dx,io_port_addremov eax,ebxadd eax,18hout dx,eax;写地址口mov dx,io_port_datain eax,dx;读数据口mov dword ptr io base address,eaxand eax,1jz findtpcl_next;检查是否为i/o基址信息mov eax,dword ptr io_base_addressand eax,Offfffffehmov dword ptrio_base_address,eax;去除i/o指示位并保存mov dx,io_port_addremov eax,ebxadd eax,Ichout dx,eax;写地址口mov dx,io_port_datain eax,dx;读数据口mov dword ptr memory_base_address,eaxand eax,Ihand eax,OfffffffOhmov dword ptr memory_base_address,eax;去除memory指示位并保存mov dx,io_port_addremov eax,ebxadd eax,3chout dx,eax;写地址口mov dx,io_port_datain eax,dx;读数据口and eax,Offhmov word ptr interrupt」ine,ax;去除interrupt其它指示位并保存mov dx,offset io9054baseaddress;显示i/o提示信息mov ah,09hint21hmov ax,word ptrio_9054base_addresscall findtpcl_disp;显示i/o基地址mov dx,offset iobaseaddress;显示i/o提示信息、mov ah,09hint21hmov ax,word ptrio_base_addresscall findtpcl_disp;显示i/o基地址mov dx,offset memorybaseaddress;显示memory提示信息mov ah,09hint21hmov ax,word ptr memory_base_address+2call findtpcl disp;显示memory基地址高16位mov ax,word ptr memory_base_addressshr ax,16call findtpcl_disp;显示memory基地址低16位mov dx,offset intnumber;显示interrupt提示信息mov ah,09hint21hmov ax,word ptrinterrupt_linecall findtpcl_disp;显示interrupt号mov dx,offset entejreturn;加回车符,换行符mov ah,09hint21hpopfdpopadretfindtpcl endpfindtpcldisp proc near;显示子程序push dxpushexpush bxmov ex,4mov bx,16findtpcldisploopl:push axpush exsub bx,4mov ex,bx shrax,cland al,Ofh;首先取低四位mov dl,al empdl,9;判断是否〈二9jle findtpcl_disp_num;若是则为O-9,ASCII码加30Hadd dl,7;否则为‘A-F\ASCII码加37Hfindtpcl_disp_num:add dl,30hmov ah,02h;显示int21hpop expopaxfindtpcl_disp endppop bxcodeends popexpop dxendstartret;子程序返回CLKO连接时钟1MHZ四.实验原理图五.实验流程图六.原程序代码产8253方式0计数器实验*;equ283h-0280hio8253aequ280h-0280hio8253bequ0cf8h;32位配置地址端口io_port_addreequ Ocfch;32位配置数据端口io_port_dataequ0540610b5h;TPC卡设备与厂商IDio_plx_iddata segmentdb4DUP0;TPC卡9054芯片I/O基地址暂存空间io_9054base_addressdb4DUP0;TPC卡I/O基地址暂存空间io_base_addressdb4DUP0;TPC卡MEMORY基地址暂存空间memory_base_addressinterrupt_line db2DUP0;TPC卡中断号暂存空间dbOdh,Oah,TPC pcicard notfind orpcicardnotfindaddress/interrupt error!!!,Odh,Oah,‘$‘io9054baseaddress dbOdh,Oah,TPC pcicard9054Chip I/O BaseAddress:,dbOdh,Oah,TPC pcicardI/O BaseAddress:,‘iobaseaddressdb Odh,Oah,TPCpcicardMemoryBaseAddress:memorybaseaddressdb Odh,Oah,TPCpcicard InterruptLine:,’$‘dbintnumberOdh,Oah,enter_returndata endsstackssegmentdb100dup stacksendscodesegmentassumecs:code,ds:data,SS:STACKS,es:data.386start:mov ax,datamov ds,axmov es,axmov ax,stacksmov ss,axcall findtpcl;查找TPC卡资源并显示mov al,14h;设置8253通道0为工作方式2,二进制计数mov dx,wordptri o_base_addres sadddx,io8253aout dx,almov dx,wordptrio base addressadddx,io8253b;送计数初值为OFHmov al,Ofhout dx,al111:in al,dx;读计数初值call disp;调显示子程序push dxmov ah,06hmov dl,Offh int21h popdx jz111mov ah,4ch int21hdisp procnear;显示子程序push dxandal,Ofh mov dl,al cmpdl,9jle num30H;退出add dl,7num:add dl,30hmov ah,02h int21hmov dl,Odh int21h;首先取低四位mov dl,Oah int21hpop dx;判断是否〈二9;若是则为‘0-9,ASCH码加;否则为‘AF,ASCH码加37H;显示;加回车符;加换行符ret;子程序返回disp endpfindtpclprocnear;查找TPC卡资源并显示pushadpushfdmov ebx,080000000hfindtpcl_next:add ebx,lOOhcmp ebx,081000000hjnz findtpcl_continuemov dx,offset pcicardnotfind;显示未找至Ijtpc卡提示信息mov ah,09hint21hmov ah,4chint21h;退出findtpcl_continue:mov dx,io_port_addremov eax,ebxout dx,eax;写地址口mov dx,io_port_datain eax,dx;读数据口cmp eax,io_plx_idmov dx,io_port_addremov eax,ebxadd eax,14hout dx,eax;写地址口mov dx,io_port_datain eax,dx;读数据口mov dword ptrio_9054base_address,eaxand eax,1jz findtpcl_next;检查是否为i/o基址信息mov eax,dword ptrio_9054base_addressand eax,Offfffffehmov dword ptrio_9054base_address,eax;去除i/o指示位并保存mov dx,io_port_addremov eax,ebxadd eax,18hout dx,eax;写地址口mov dx,io_port_datain eax,dx;读数据口mov dwordptriobaseaddress,eaxand eax,1jz findtpcl_next;检查是否为i/o基址信息mov eax,dwordptrio_base_address and eax,Offfffffeh指示位并保存mov dwordptrio_base_address,eax;去除i/omov dx,io_port_addremov eax,ebxadd eax,Ichout dx,eax;写地址口mov dx,io_port_datain eax,dx;读数据口mov dwordptrmemorybaseaddress,eaxand eax,Ihjnz findtpcl next;检查是否为memory基址信息mov eax,dwordptrmemory_base_addressand eax,OfffffffOhmov dwordptrmemory_base_address,eax;去除memory指示位并保存mov dx,io_port_addremov eax,ebxadd eax,3chout dx,eax;写地址口mov dx,io_port_datain eax,dx;读数据口andeax,Offhinterrupt其它指示位并保存mov dx,offset io9054baseaddress;显不1/提不信息mov ah,09hint21hmov ax,wordptrio9054base_addresscall findtpcl_disp;显示i/o基地址mov dx,offset iobaseaddress;显示i/o提示信息mov ah,09hint21hmov ax,wordptriobaseaddresscall findtpcl_disp;显示i/o基地址mov dx,offset memorybaseaddress;显示memory提示信息mov ah,09hint21hmov ax,wordptrmemory_base_address+2call findtpcl_disp;显示memory基地址高16位mov ax,wordptrmemory_base_addressshr ax,16call findtpcl_disp;显示memory基地址低16位mov dx,offset intnumber;显示interrupt提示信息mov ah,09h int21hmov ax,wordptrinterrupt_linecall findtpcl disp;显示interrupt号mov dx,offset enter_return;加回车符,换行符movah,09hint21hpopfdpopadretfindtpcl endpfindtpcl_dispprocnear;显示子程序push dxpushexpush bxmovex,4mov bx,16findtpcl_disp_loopl:push axpushexsubbx,4movex,bxshr ax,cland al,Ofh;首先取低四位movdl,al empdl,9;判断是否<二9。