51單片機數碼管顯示32767以下的數字正常,32768以上的數字就是亂碼,是數據類型定義錯誤嗎?應該怎么改?我現在自學51,小白一個,求大佬指導!
原程序如下:
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit WE1 = P2^2;
sbit WE2 = P2^3;
sbit WE3 = P2^4;
uint i,ge,shi,bai,qian,wan;
void delay(uint z)
{
uint x,y;
for( x = z; x > 0; x--)
for(y = 124; y > 0; y--);
}
uint code duan[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void display(i)
{
ge = i%10;
shi = i%100/10;
bai = i%1000/100;
qian = i%10000/1000;
wan = i/10000;
WE1 = 1;
WE2 = 1;
WE3 = 1;
P0 = duan[ge];
delay(1);
P0 = 0x00;
WE1 = 0;
WE2 = 1;
WE3 = 1;
P0 = duan[shi];
delay(1);
P0 = 0x00;
WE1 = 1;
WE2 = 0;
WE3 = 1;
P0 = duan[bai];
delay(1);
P0 = 0x00;
WE1 = 0;
WE2 = 0;
WE3 = 1;
P0 = duan[qian];
delay(1);
P0 = 0x00;
WE1 = 1;
WE2 = 1;
WE3 = 0;
P0 = duan[wan];
delay(1);
P0 = 0x00;
}
void main()
{
while(1)
{
i = 32768;
display(i);
}
}
另外在51上計數器最大能計多大的數,它的數據類型最大能定義多大的,比如我想計到50億,然后讓這個數在數碼管上顯示出來
|