中断系统练习题之中断应用

一、题目:中断系统练习:外部中断每发生一次在数码管上显示一个数字,  且每中断一次显示的数值增1或减1 外 部中断0为增1,外部中断1为减1。

#include<reg52.h>

typedef  unsigned int uint;

void delay(int x)
{
	int a, b;
	for(a=x; a>0; a--)
		for(b=500; b>0; b--);


}


uint array[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x98};
uint m=0;

int main()
{
	P0=0xff;
	EA=1;
	EX0=1; 
	IT0=1;
	EX1=1;
	IT1=1;
	while(1);


	return 0;
}

void INT_0() interrupt 0
{
	EX0=0;
	delay(20);
	EX0=1;
	if(m==10)
		m=0;
	else P0=array[m++];



}

void INT_1()interrupt 2
{
	EX1=0;
	delay(20);
	EX1=1;
	if(m==0)
		m=10;
	else P0=array[--m];	


}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值