- 1、本文档共21页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
《计算机接口编程术》实验程序
第一章 微型计算机接口寻址
//端口选址程序:
实验电路接线关系:
序号 D触发器信号段 其他电路信号段 1 SD置位信号端 +5V 2 RD复位信号端 Y5地址译码器输出(正常高电平) 3 CLK时钟输入端 Y4地址译码器输出(正常高电平) 4 D数据输入端 +5V电源 5 Q信号输出端 L7 LED管电源 6 D触发器信号段 其他电路信号段 2、程序清单
#include dos.h
main()
{
while(1){
outportb(0xec00+0x2A0-0x280,100);/*选择Y4*/
delay(10000);
outportb(0xec00+0x2A8-0x280,100 ); /*选择Y5*/
delay(10000);
if(kbhit()) break;
}
}
中断计数
(一)单脉冲触发中断计数程序
硬件接线
8259管脚编号:
编号 名称 编号 名称 编号 名称 编号 名称 1 CS 8 D3 15 CS3 22 IR4 2 WR 9 D2 16 SP/EN 23 IR5 3 RD 10 D1 17 INT 24 IR6 4 D7 11 D0 18 IR0 25 IR7 5 D6 12 CS0 19 IR1 26 INTA 6 D5 13 CS1 20 IR2 27 A0 7 D4 14 GND 21 IR3 28 VCC 接线关系:
8259A 实验仪 8259A 实验仪 1 CS 2B0H 15 CS3 ? 2 WR IOW 16 SP/EN 3 RD IOR 17 INT ? 4 D7 D7 18 IR0 单脉冲1 5 D6 D6 19 IR1 单脉冲2 6 D5 D5 20 IR2 7 D4 D4 21 IR3 8 D3 D3 22 IR4 ? 9 D2 D2 23 IR5 10 D1 D1 24 IR6 11 D0 D0 25 IR7 12 CS0 26 INTA +5V 13 CS1 27 A0 A0 14 GND GND 28 VCC +5V
2、程序流程
3、程序清单
//T8259-1.c
#include stdio.h /*header file */
#include stdlib.h
#include conio.h
#include dos.h
void is0(),is1(); /*function */
unsigned int io82590=0xec30,io82591=0xec31;
unsigned char icw1=0x13,icw4=1,ocw1=0xfc,ocw2=0x20,ocw3=0xce;
void main()
{
int i,j;
outportb(io82590,icw1); /* init */
outportb(io82591,icw4);
outportb(io82591,ocw1);
while(!kbhit()) /* key check */
{
outportb(io82590,ocw3); /*read status command */
i=inportb(io82590); /*read status */
if((i0x80)==0x80) /*check int irr */
{
if((i7)==0) is0(); /* irr0 */
if((i7)==1) is1(); /* irr1 */
}
}
}
void is0() /*int ir0 service */
{
printf(0);
outportb(io82590,ocw2);
}
void is1() /*int ir1 service */
{
printf(1 );
outportb(io82590,ocw2);
}
(二)BIOS和DOS调用程序
1、DOS调用程序
#includestdio.h
#includedos.h
main()
{
union REGS inreg,outreg;
unsigned int year1;
unsigned char month1,date1;
clrscr();
inreg.h.ah=0x2a;
gotoxy(10,10);
intdos(inreg,outreg)
文档评论(0)