做中断的时候后面一部分关于数码管的代码看上去好像没执行
题目:
STC89C52RC 锁存器:74HC573 74HC138
代码:
中断3.c:
#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
#include<74HC138D.h>
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uint num_1=432,num_0=0,n=0,aa=0xfe;
void delayms ( uint );
void main ()
{
TMOD=0x11;
EA=1;
ET1=1;
ET0=1;
TR1=1;
TR0=1;
TH1=(65536-10000)/256;
TL1=(65536-10000)%256;
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
P1=aa;
while(1)
{
wexuan(3);
dula=1;
P0=table[7];
dula=0;
P0=0x00;
wexuan(4);
dula=1;
P0=table[6];
dula=0;
P0=0x00;
wexuan(5);
dula=1;
P0=table[5];
dula=0;
P0=0x00;
if( num_1>=398 )
{
wexuan(6);
dula=1;
P0=table[num_1/100];
dula=0;
P0=0x00;
wexuan(7);
dula=1;
P0=table[(num_1%100)/10];
dula=0;
P0=0x00;
wexuan(8);
dula=1;
P0=table[num_1%10];
dula=0;
P0=0x00;
}
else num_1=330;
if( num_0>=50 )
{
P1=aa;
aa=_cror_(aa,1);
num_0=0;
}
if( n > 300 )
{
wexuan(8);
dula=1;
P0=table[0];
dula=0;
P0=0x00;
wexuan(7);
dula=1;
P0=0xe3;
dula=0;
P0=0x00;
wexuan(6);
dula=1;
P0=0xe3;
dula=0;
P0=0x00;
wexuan(5);
dula=1;
P0=table[14];
dula=0;
P0=0x00;
wexuan(4);
dula=1;
P0=0x91;
dula=0;
P0=0x00;
while(1)
{
P1=0x00;
delayms(500);
P1=0xff;
delayms(500);
}
}
}
}
void delayms ( uint xms )
{
int i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void
time_1() interrupt 3
{
TH1=(65536-10000)/256;
TL1=(65536-10000)%256;
num_1--;
}
void time_0() interrupt 1
{
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
num_0++;
n++;
}
一周热门 更多>