89C52单片机的共阴数码管怎么显示数字0-99(c语言)

2019-07-15 14:23发布

为什么十位会和个位显示一样
#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
sbit dula=P2^6;
sbit wela=P2^7;
sbit d1=P1^0;
uchar code table[]={
0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,
0xc6,0xa1,0x86,0x8e};
uchar ge,shi,aa;
uint temp;
void main()
{
temp = 0;
TMOD = 0x01;
TH0=(65536-50000)/256;
TH0=(65536-50000)%256;
EA = 1;
ET0 = 1;
TR0=1;
aa=0;


while(1){
shi=temp/10;
ge=temp%10;
dula=1;
P0=table[shi];
dula=0;
P0=0xc0;
wela=1;
P0=0xc1;
wela=0;


dula=1;
P0=table[ge];
dula=0;
P0=0xc0;
wela=1;
P0=0xc2;
wela=0;
}
}
void timer0 () interrupt 1
{
TH0 = (65536 - 50000)/256;
TL0 = (65536 - 50000)%256;
aa++;
if(aa==20){
if(temp==99)
temp=0;
temp++;
aa=0;
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。