本帖最后由 yangbo19881118 于 2013-4-14 19:04 编辑
板子是郭天翔系列的!问题时进入外部中断后不会退出,P1口的值不会变。用定时器写的时钟没有影响,继续运行!改了几天了,确实想不出问题来了!编译什么的都通过...求大神们提点提点哇!!!!!跪求!
#include"reg52.h"#define uchar unsigned char
#define uint unsigned int
sbit dula=P2^6;
sbit wela=P2^7;
uint m,n,miao,miao_1,shi,shi_1,fen,fen_1,z;
void delay1ms(uint);
void shuma(uint,uint,uint,uint,uint,uint);
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f};
void TO() interrupt 1
{
TH0 =(65536-50000)/256;
TL0 =(65536-50000)%256;
m++;
}
void INT1_0() interrupt 2
{
P1=0xfe;
}
void main()
{
TMOD=0x01;
TH0 =(65536-50000)/256;
TL0 =(65536-50000)%256;
EA = 1;
ET0 = 1;
EX1 = 1;
TR0 = 1;
IT1 = 1;
while(1)
{
if(m==20) //1秒时间到了
{
m=0;
miao++;
if(miao>9)
{
miao=0;
miao_1++;
if(miao_1>5)
{
miao_1=0;
fen++;
if(fen>9)
{
fen=0;
fen_1++;
if(fen_1>5)
{
fen_1=0;
shi++;
if(shi>9)
{
shi=0;
shi_1++;
}
}
}
}
}
}
shuma(miao,miao_1,fen,fen_1,shi,shi_1);
}
}
}
void shuma(uint a,uint b,uint c,uint d,uint e,uint f) //数码管显示函数
{
dula=1;
P0 =table[a];
dula=0;
P0 =0xff;
wela=1;
P0 =0xdf;
wela=0;
delay1ms(5);
dula=1;
P0 =table;
dula=0;
P0 =0xff;
wela=1;
P0 =0xef;
wela=0;
delay1ms(5);
dula=1;
P0 =table[c];
dula=0;
P0 =0xff;
wela=1;
P0 =0xf7;
wela=0;
delay1ms(5);
dula=1;
P0 =table[d];
dula=0;
P0 =0xff;
wela=1;
P0 =0xfb;
wela=0;
delay1ms(5);
dula=1;
P0 =table[e];
dula=0;
P0 =0xff;
wela=1;
P0 =0xfd;
wela=0;
delay1ms(5);
dula=1;
P0 =table[f];
dula=0;
P0 =0xff;
wela=1;
P0 =0xfe;
wela=0;
delay1ms(5);
}
void delay1ms(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=60;y>0;y--);
} |