|
为什么把代码下到单片机上运行先开始数码管有显示,但不正确,最后八个数码管都灭了。。。。请教各位
#include
typedef unsigned char uchar;
typedef unsigned int uint;
uchar code shumashuzi[ ]={0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8,
0x80, 0x90, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E }; //共阳
uint TH00,TL00;
uchar x=0;
uint b=0;
uchar c=0;
sbit yi=P2^0;
sbit er=P2^1; //38译码器控制
sbit san=P2^2;
#define xianshi P0
uchar shumashuzi_[ ]={0x00};
void delay_ms(uint );
void unit( );
void main ( ){
unsigned long sum=0;
unit ( );
while(1){
if(x==1){
x=0;
sum++;
shumashuzi_[7]=shumashuzi[sum%10];
shumashuzi_[6]=shumashuzi[sum/10%10];
shumashuzi_[5]=shumashuzi[sum/100/10%10];
shumashuzi_[4]=shumashuzi[sum/1000/100/10%10]; //八个数码管每个的显示
shumashuzi_[3]=shumashuzi[sum/10000/1000/100/10%10];
shumashuzi_[2]=shumashuzi[sum/100000/10000/1000/100/10%10];
shumashuzi_[1]=shumashuzi[sum/1000000/100000/10000/1000/100/10%10];
shumashuzi_[0]=shumashuzi[sum/10000000/1000000/100000/10000/1000/100/10%10];
}
}
}
void delay_ms(uint time ){
uint i,j;
for(i=0;i |
|