單片機(jī)C語言程序設(shè)計(jì):INT0 及 INT1 中斷計(jì)數(shù)
Buffer_Counts[1]=0x0a;
Buffer_Counts[5]=Count_B/100;
Buffer_Counts[4]=Count_B%100/10;
Buffer_Counts[3]=Count_B%10;
if( Buffer_Counts[5]==0)
{
Buffer_Counts[5]=0x0a;
if( Buffer_Counts[4]==0)
Buffer_Counts[4]=0x0a;
}
for(i=0;i6;i++)
{
P2=DSY_Scan_Bits[i];
P1=DSY_CODE[Buffer_Counts[i]];
DelayMS(1);
}
}
//主程序
void main()
{
IE=0x85;
PX0=1;中斷優(yōu)先
IT0=1;
IT1=1;
while(1)
{
if(K3==0) Count_A=0;
if(K4==0) Count_B=0;
Show_Counts();
}
}
//INT0 中斷函數(shù)
void EX_INT0() interrupt 0
{
Count_A++;
}
//INT1 中斷函數(shù)
void EX_INT1() interrupt 2
{
Count_B++;
}
c語言相關(guān)文章:c語言教程
評論