东北大学秦皇岛分校微型接口及技术实验报告.docx

上传人:b****6 文档编号:12559982 上传时间:2023-06-06 格式:DOCX 页数:30 大小:269.07KB
下载 相关 举报
东北大学秦皇岛分校微型接口及技术实验报告.docx_第1页
第1页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第2页
第2页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第3页
第3页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第4页
第4页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第5页
第5页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第6页
第6页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第7页
第7页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第8页
第8页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第9页
第9页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第10页
第10页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第11页
第11页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第12页
第12页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第13页
第13页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第14页
第14页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第15页
第15页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第16页
第16页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第17页
第17页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第18页
第18页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第19页
第19页 / 共30页
东北大学秦皇岛分校微型接口及技术实验报告.docx_第20页
第20页 / 共30页
亲,该文档总共30页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

东北大学秦皇岛分校微型接口及技术实验报告.docx

《东北大学秦皇岛分校微型接口及技术实验报告.docx》由会员分享,可在线阅读,更多相关《东北大学秦皇岛分校微型接口及技术实验报告.docx(30页珍藏版)》请在冰点文库上搜索。

东北大学秦皇岛分校微型接口及技术实验报告.docx

东北大学秦皇岛分校微型接口及技术实验报告

 

 

微型计算机接口技术实验报告

学号:

213****

姓名:

提交日期:

2016-4-22

成绩:

 

东北大学秦皇岛分校计算机与通信工程学院

2016

【实验编号】

1

【实验名称】

实验三可编程定时器计数器8253

【实验内容】

1.可编程定时器计数器8253

(一)

实验说明

实验原理图:

实验流程图:

ASM程序:

ioportequ0d400h-0280h

io8253aequioport+280h

io8253bequioport+281h

io8253cequioport+283h

codesegment

assumecs:

code

start:

movdx,io8253c;向8253写控制字

moval,36h;使0通道为工作方式3

outdx,al

movax,1000;写入循环计数初值1000

movdx,io8253a

outdx,al;先写入低字节

moval,ah

outdx,al;后写入高字节

movdx,io8253c

moval,76h;设8253通道1工作方式2

outdx,al

movax,1000;写入循环计数初值1000

movdx,io8253b

outdx,al;先写低字节

moval,ah

outdx,al;后写高字节

movah,4ch;程序退出

int21h

codeends

endstart

CPP程序:

/******************************/

/*可编程定时器/计数器

(二)*/

/******************************/

#include

#include

#include"ApiEx.h"

#pragmacomment(lib,"ApiEx.lib")

voidmain()

{

printf("--------------------EXP9_3_8253_2---------------------\n");

printf("1.8253(CLK0)===(1MHz)or(2MHz)\n");

printf("2.TPC(+5V)===8253(GATE0,GATE1)\n");

printf("3.8253(OUT0)===8253(CLK1)\n");

printf("4.8253(OUT1)===LJB(Ui)\n");

printf("5.I/O(280-287)===8253(CS)\n");

printf("Pressanykeytobegin!

\n\n");

getch();

if(!

Startup())/*打开设备*/

{

printf("ERROR:

OpenDeviceError!

\n");

return;

}

PortWriteByte(0x283,0x36);/*写方式字通道0方式3*/

PortWriteByte(0x280,1000%256);/*送计数初值*/

PortWriteByte(0x280,1000/256);

PortWriteByte(0x283,0x76);/*设置计数器1方式字*/

PortWriteByte(0x281,1000%256);/*送计数初值*/

PortWriteByte(0x281,1000/256);

Cleanup();/*关闭设备*/

printf("Pressanykeytoexit!

");

getch();

}

2.可编程定时器计数器8253

(二)

实验说明:

实验原理图:

实验流程图:

ACM程序:

ioportequ0d400h-0280h

io8253aequioport+283h

io8253bequioport+280h

codesegment

assumecs:

code

start:

moval,14h;设置8253通道0为工作方式2,二进制计数

movdx,io8253a

outdx,al

movdx,io8253b;送计数初值为0FH

moval,0fh

outdx,al

lll:

inal,dx;读计数初值

calldisp;调显示子程序

pushdx

movah,06h

movdl,0ffh

int21h

popdx

jzlll

movah,4ch;退出

int21h

dispprocnear;显示子程序

pushdx

andal,0fh;首先取低四位

movdl,al

cmpdl,9;判断是否<=9

jlenum;若是则为'0'-'9',ASCII码加30H

adddl,7;否则为'A'-'F',ASCII码加37H

num:

adddl,30h

movah,02h;显示

int21h

movdl,0dh;加回车符

int21h

movdl,0ah;加换行符

int21h

popdx

ret;子程序返回

dispendp

codeends

endstart

CPP程序:

/********************************/

/*可编程定时器/计数器

(一)*/

/********************************/

#include

#include

#include"ApiEx.h"

#pragmacomment(lib,"ApiEx.lib")

voidmain()

{

BYTEdata;

if(!

Startup())/*打开设备*/

{

printf("ERROR:

OpenDeviceError!

\n");

return;

}

PortWriteByte(0x283,0x10);/*设8253计数器0工作方式0,只写低字节*/

PortWriteByte(0x280,0x20);/*写入计数初值32*/

while(!

kbhit())/*有键按下则退出*/

{

PortReadByte(0x280,&data);

printf("%d\n",data);/*打印计数器值*/

}

Cleanup();/*关闭设备*/

}

 

【实验编号】

2

【实验名称】

实验五七段数码管

【实验内容】

1.七段数码管静态显示

实验说明:

实验原理图:

实验流程图:

ACM程序:

datasegment

ioportequ0d400h-0280h

io8255aequioport+288h

io8255bequioport+28bh

leddb3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh

mesg1db0dh,0ah,'Inputanum(0--9h):

',0dh,0ah,'$'

dataends

codesegment

assumecs:

code,ds:

data

start:

movax,data

movds,ax

movdx,io8255b;使8255的A口为输出方式

movax,80h

outdx,al

sss:

movdx,offsetmesg1;显示提示信息

movah,09h

int21h

movah,01;从键盘接收字符

int21h

cmpal,'0';是否小于0

jlexit;若是则退出

cmpal,'9';是否大于9

jgexit;若是则退出

subal,30h;将所得字符的ASCII码减30H

movbx,offsetled;bx为数码表的起始地址

xlat;求出相应的段码

movdx,io8255a;从8255的A口输出

outdx,al

jmpsss;转SSS

exit:

movah,4ch;返回DOS

int21h

codeends

CPP程序:

/**************************/

/*七段数码管

(一)*/

/**************************/

#include

#include

#include"ApiEx.h"

#pragmacomment(lib,"ApiEx.lib")

charled[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

/*上面为从0-9对应的段码表*/

voidmain()

{

intout;

if(!

Startup())/*打开设备*/

{

printf("ERROR:

OpenDeviceError!

\n");

return;

}

PortWriteByte(0x28b,0x80);/*设8255A口C口输出*/

printf("\nInputanumber(0--9),otherkeytoexit!

:

\n");/*显示提示*/

while(true)

{

out=getch();

if(out<0x30||out>0x39)break;

printf("%c\n",out);

PortWriteByte(0x288,led[out-48]);

}

Cleanup();/*关闭设备*/

}

2.七段数码管动态显示

实验说明:

实验原理图:

实验流程图:

ACM程序:

datasegment

ioportequ0d400h-0280h

io8255aequioport+28ah

io8255bequioport+28bh

io8255cequioport+288h

leddb3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh;段码

buffer1db5,6;存放要显示的个位和十位

bzdw?

;位码

dataends

codesegment

assumecs:

code,ds:

data

start:

movax,data

movds,ax

movdx,io8255b;将8255设为A口输出

moval,80h

outdx,al

movdi,offsetbuffer1;设di为显示缓冲区

loop2:

movbh,02

lll:

movbyteptrbz,bh

pushdi

decdi

adddi,bz

movbl,[di];bl为要显示的数

popdi

moval,0

movdx,io8255a

outdx,al

movbh,0

movsi,offsetled;置led数码表偏移地址为SI

addsi,bx;求出对应的led数码

moval,byteptr[si]

movdx,io8255c;自8255A的口输出

outdx,al

moval,byteptrbz;使相应的数码管亮

movdx,io8255a

outdx,al

movcx,3000

delay:

loopdelay;延时

movbh,byteptrbz

shrbh,1

jnzlll

movdx,0ffh

movah,06

int21h

jeloop2;有键按下则退出

movdx,io8255a

moval,0;关掉数码管显示

outdx,al

movah,4ch;返回

int21h

codeends

endstart

CPP程序:

/************************/

/*七段数码管

(二)*/

/************************/

#include

#include

#include"ApiEx.h"

#pragmacomment(lib,"ApiEx.lib")

voidmain()

{

printf("--------------------EXP11_5_LED_2---------------------\n");

printf("1.8255(PA0-PA6)===LED(a-g)\n");

printf("2.8255(PC0-PC1)===LED(S0-S1)\n");

printf("3.I/O(288-28F)===8255(CS)\n");

printf("4.TPC(GND)===LED(dp)\n");

printf("Pressanykeytobegin!

\n\n");

getch();

if(!

Startup())/*打开设备*/

{

printf("ERROR:

OpenDeviceError!

\n");

return;

}

printf("Pleaseenteranykeyreturn!

");

do{

PortWriteByte(0x28b,0x82);/*设置8255的A口C口均为输出*/

PortWriteByte(0x288,0x6d);

PortWriteByte(0x28a,0x02);/*显示十位5*/

Sleep(1000);

PortWriteByte(0x288,0x7d);

PortWriteByte(0x28a,0x01);/*显示个位6*/

Sleep(1000);

}while(!

kbhit());

PortWriteByte(0x28a,0x00);

Cleanup();/*关闭设备*/

}

 

【实验编号】

3

【实验名称】

实验八交通灯控制实验

【实验内容】

实验说明

1.实验目的

通过并行接口8255实现十字路口交通灯的模拟控制,进一步掌握对并行口的使用。

二.实验内容

如图-29,L7、L6、L5作为南北路口的交通灯与PC7、PC6、PC5相连,L2、L1、L0作为东西路口的交通灯与PC2、PC1、PC0相连。

编程使六个灯按交通灯变化规律亮灭。

三.编程提示:

十字路口交通灯的变化规律要求:

(1)南北路口的绿灯、东西路口的红灯同时亮30秒左右。

(2)南北路口的黄灯闪烁若干次,同时东西路口的红灯继续亮。

(3)南北路口的红灯、东西路口的绿灯同时亮30秒左右。

(4)南北路口的红灯继续亮、同时东西路口的黄灯亮闪烁若干次。

(5)转

(1)重复。

实验原理

实验流程图

Asm程序:

;***********************************;

;*十字路口红绿灯模拟演示程序*;

;*端口各灯的设置:

*;

;*1红1黄1绿002红2黄2绿*;

;***********************************;

io8255aequ28ah-0280h

io8255bequ28bh-0280h

io_port_addreequ0cf8h;32位配置地址端口

io_port_dataequ0cfch;32位配置数据端口

io_plx_idequ0540610b5h;TPC卡设备及厂商ID

datasegment

portc1db24h,44h,04h,44h,04h,44h,04h;六个灯可能

db81h,82h,80h,82h,80h,82h,80h;的状态数据

db0ffh;结束标志

io_9054base_addressdb4DUP(0);TPC卡9054芯片I/O基地址暂存空间

io_base_addressdb4DUP(0);TPC卡I/O基地址暂存空间

memory_base_addressdb4DUP(0);TPC卡MEMORY基地址暂存空间

interrupt_linedb2DUP(0);TPC卡中断号暂存空间

pcicardnotfinddb0dh,0ah,'TPCpcicardnotfindoraddress/interrupterror!

!

!

',0dh,0ah,'$'

io9054baseaddressdb0dh,0ah,'TPCpcicard9054ChipI/OBaseAddress:

','$'

iobaseaddressdb0dh,0ah,'TPCpcicardI/OBaseAddress:

','$'

memorybaseaddressdb0dh,0ah,'TPCpcicardMemoryBaseAddress:

','$'

intnumberdb0dh,0ah,'TPCpcicardInterruptLine:

','$'

enter_returndb0dh,0ah,'$'

dataends

stackssegment

db100dup(?

stacksends

codesegment

assumecs:

code,ds:

data,SS:

STACKS,es:

data

.386;386模式编译

start:

movax,data

movds,ax

moves,ax

movax,stacks

movss,ax

callfindtpc1;查找TPC卡资源并显示

movdx,wordptrio_base_address

adddx,io8255b

moval,90h

outdx,al;设置8255为C口输出

movdx,wordptrio_base_address

adddx,io8255a

re_on:

movbx,0

on:

moval,portc1[bx]

cmpal,0ffh

jzre_on

outdx,al;点亮相应的灯

incbx

movcx,5000;参数赋初值

testal,21h;是否有绿灯亮

jzde1;没有,短延时

movcx,45000;有,长延时

de1:

movdi,65000;di赋初值9000

de0:

decdi;减1计数

jnzde0;di不为0

loopde1

pushdx

movah,06h

movdl,0ffh

int21h

popdx

jzon;没有,转到on

exit:

movah,4ch;返回DOS

int21h

findtpc1procnear;查找TPC卡资源并显示

pushad

pushfd

movebx,080000000h

findtpc1_next:

addebx,100h

cmpebx,081000000h

jnzfindtpc1_continue

movdx,offsetpcicardnotfind;显示未找到tpc卡提示信息

movah,09h

int21h

movah,4ch

int21h;退出

findtpc1_continue:

movdx,io_port_addre

moveax,ebx

outdx,eax;写地址口

movdx,io_port_data

ineax,dx;读数据口

cmpeax,io_plx_id

jnzfindtpc1_next;检查是否发现tpc卡

movdx,io_port_addre

moveax,ebx

addeax,14h

outdx,eax;写地址口

movdx,io_port_data

ineax,dx;读数据口

movdwordptrio_9054base_address,eax

andeax,1

jzfindtpc1_next;检查是否为i/o基址信息

moveax,dwordptrio_9054base_address

andeax,0fffffffeh

movdwordptrio_9054base_address,eax;去除i/o指示位并保存

movdx,io_port_addre

moveax,ebx

addeax,18h

outdx,eax;写地址口

movdx,io_port_data

ineax,dx;读数据口

movdwordptrio_base_address,eax

andeax,1

jzfindtpc1_next;检查是否为i/o基址信息

moveax,dwordptrio_base_address

andeax,0fffffffeh

movdwordptrio_base_address,eax;去除i/o指示位并保存

movdx,io_port_addre

moveax,ebx

addeax,1ch

outdx,eax;写地址口

movdx,io_port_data

ineax,dx;读数据口

movdwordptrmemory_base_address,eax

andeax,1h

jnzfindtpc1_next;检查是否为memory基址信息

moveax,dwordptrmemory_base_address

andeax,0fffffff0h

movdwordptrmemory_base_address,eax;去除memory指示位并保存

movdx,io_port_addre

moveax,ebx

addeax,3ch

outdx,eax;写地址口

movdx,io_port_data

ineax,dx;读数据口

andeax

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2