Home > other >  Excuse me, why not? Send a, 49 says digital tube display
Excuse me, why not? Send a, 49 says digital tube display

Time:09-26

#include
Unsigned char flag, bai, shi, ge, shiwan, wan, qian;
# define uint unsigned int
# define uchar unsigned char
Uint a;
sbit wela=P2^7;
sbit dula=P2^6;
Unsigned char code table []={x5b x3f 0, 0 x06, 0, 0 x4f, 0 x66, 0 x6d,
X07 0 x7d, 0, 0 x7f, 0 x6f, 0 x77, 0 x7c,
X5e 0 x39, 0, 0 x79, 0 x71};
Void delay (uint z)
{
Uint x, y;
For (x=z; X> 0; X -)
For (y=110; Y> 0; y--);
}
Void the display (uchar bai, uchar shi, uchar ge, uchar shiwan, uchar wan, uchar qian)
{
dula=1;
P0=table [shiwan];
dula=0;
P0=0 XFF;
wela=1;
P0=0xfe;
wela=0;
delay(1);

dula=1;
P0=table (wan);
dula=0;
P0=0 XFF;
wela=1;
P0=0xfd;
wela=0;
delay(1);

dula=1;
[qian P0=table];
dula=0;
P0=0 XFF;
wela=1;
P0=0xfb;
wela=0;
delay(1);

dula=1;
P0=table (bai);
dula=0;
P0=0 XFF;
wela=1;
P0=0xf7;
wela=0;
delay(1);

dula=1;
P0=table (shi);
dula=0;
P0=0 XFF;
wela=1;
P0=0xef;
wela=0;
delay(1);

dula=1;
P0=table (ge),
dula=0;
P0=0 XFF;
wela=1;
P0=0xdf;
wela=0;
delay(1);
}
Void main ()
{
Flag=1;
SCON=0 x50;//set the serial port works, 0101, 0000
PCON=0 x00;
TMOD=0 x20;
TH1=0 XFD;
TL1=0 XFD;
TR1=1;
EA=1;
ES=1;
While (1)
{
If (flag==1)
{
ES=0;
Flag=0;
SBUF=a;
while(! TI);
TI=0;
ES=1;
}
The display (bai shi, ge, shiwan, wan, qian);
}
}
Void serial interrupt 4 ()
{
RI=0;
A=SBUF;
Shiwan=a/100000;
Wan a %=100000/10000;
Qian a %=10000/1000;
Bai a %=1000/100;
Shi=a % 100/10;
Ge=a % 10;
}

CodePudding user response:

The building Lord, PC sends 1 is ASCii, read into the single chip microcomputer to minus 0 x30,

CodePudding user response:

#include
Unsigned char flag, bai, shi, ge, shiwan, wan, qian;
# define uint unsigned int
# define uchar unsigned char
Uint a;
sbit wela=P2^7;
sbit dula=P2^6;
Unsigned char code table []={x5b x3f 0, 0 x06, 0, 0 x4f, 0 x66, 0 x6d,
X07 0 x7d, 0, 0 x7f, 0 x6f, 0 x77, 0 x7c,
X5e 0 x39, 0, 0 x79, 0 x71};
Void delay (uint z)
{
Uint x, y;
For (x=z; X> 0; X -)
For (y=110; Y> 0; y--);
}
Void the display (uchar bai, uchar shi, uchar ge, uchar shiwan, uchar wan, uchar qian)
{
dula=1;
P0=table [shiwan];
dula=0;
P0=0 XFF;
wela=1;
P0=0xfe;
wela=0;
delay(1);

dula=1;
P0=table (wan);
dula=0;
P0=0 XFF;
wela=1;
P0=0xfd;
wela=0;
delay(1);

dula=1;
[qian P0=table];
dula=0;
P0=0 XFF;
wela=1;
P0=0xfb;
wela=0;
delay(1);

dula=1;
P0=table (bai);
dula=0;
P0=0 XFF;
wela=1;
P0=0xf7;
wela=0;
delay(1);

dula=1;
P0=table (shi);
dula=0;
P0=0 XFF;
wela=1;
P0=0xef;
wela=0;
delay(1);

dula=1;
P0=table (ge),
dula=0;
P0=0 XFF;
wela=1;
P0=0xdf;
wela=0;
delay(1);
}
Void main ()
{
Flag=1;
SCON=0 x50;//set the serial port works, 0101, 0000
PCON=0 x00;
TMOD=0 x20;
TH1=0 XFD;
TL1=0 XFD;
TR1=1;
EA=1;
ES=1;
While (1)
{
If (flag==1)
{
ES=0;
Flag=0;
SBUF=a;
while(! TI);
TI=0;
ES=1;
}
The display (bai shi, ge, shiwan, wan, qian);
}
}
Void serial interrupt 4 ()
{
RI=0;
A=SBUF;
A=a - 0 x30;
Shiwan=a/100000;
Wan a %=100000/10000;
Qian a %=10000/1000;
Bai a %=1000/100;
Shi=a % 100/10;
Ge=a % 10;
} it shows 65489

CodePudding user response:

The building Lord, your PC or hexadecimal characters is sent?
The sending hex is 1, 1-48-47654 is converted to a negative number is 89-47; Characters' 1 ', was the last time sent convert hexadecimal is 0 x31, 49,

CodePudding user response:

I sent in a text mode,

CodePudding user response:

The
reference 4 floor an_ch reply:
I sent in a text mode,

After the text mode should be a character, how would be 65489 a? Trouble the landlord to send the PC software cut a figure,
  • Related