我想让数码管按一秒一次的变化数字,我用的12m的晶振,程序写进去以后直接显示两个8,加了一个for偱环发现,数码管可以变化,那就是我写的中断没起做用,我新手实在看不出为什么这个中断为什么没起做用,高手帮我看看,谢谢了
#include<reg52.h>
int a,b,c;
unsigned char code table[]=
{0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
sbit duan=P2^6;
sbit wei=P2^7;
void main()
{
c=0;
a=0;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
a=0;
wei=1;
P0=0x03;
wei=0;
while(1)
{
if(c==20)
c=0;
a++;
if(a==10)
a=0;
duan=1;
P0=table[a];
duan=0;
// for(b=10000;b>0;b--);
}
}
void time0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
c++;
}
#include<reg52.h>
int a,b,c;
unsigned char code table[]=
{0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
sbit duan=P2^6;
sbit wei=P2^7;
void main()
{
c=0;
a=0;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
a=0;
wei=1;
P0=0x03;
wei=0;
while(1)
{
if(c==20)
c=0;
a++;
if(a==10)
a=0;
duan=1;
P0=table[a];
duan=0;
// for(b=10000;b>0;b--);
}
}
void time0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
c++;
}