#include
Typedef unsigned int uint;
Typedef unsigned char uchar;
Sbit A0=P2 ^ 2;
Sbit A1=P2 ^ 3;
Sbit A2=P2 ^ 4;
Uint num.
Void delay (uint I)
{
while(i--);
}
Void the display (uint I)
{
Uchar, bai shi ge;
Uchar a [10]={x5b x3f 0, 0 x06, 0, 0 x4f, 0 x66, 0 x6d, 0 x7d, 0 x07, 0 x7f, 0 x6f};
Bai=I/100;
Shi=I % 100/10;
Ge=I % 10;
P0=0 x00;
A0=0; A1=0; A2=0;
P0=a (ge);
Delay (100);
P0=0 x00;
A0=1; A1=0; A2=0;
P0=a (shi);
Delay (100);
P0=0 x00;
A0=0; A1=1; A2=0;
P0=a (bai);
Delay (100);
}
Void UARTInit ()
{
EA=1;//open the total interruption
ES=1;//open the serial port interrupt allows a
SM0=0; The SM1=1;//set the serial working mode
REN=1;//open the serial port, allowing a serial port to send and receive data
TR1=1;//start the timer 1 to generate baud rate
TMOD=0 x20;//set the operation mode of the timer 1
TH1=0 XFD;//set the baud rate of 9600, after calculating the TL1 initial value for 253 can produce 9600 baud rate
TL1=0 XFD;
}
Void UART interrupt ()
4{
If (RI)
{
Num=SBUF;
RI=0;//software reset accepts mark a
}
The display (num);
}
Void main ()
{
While (1)
{
UARTInit ();
}
}
CodePudding user response:
The 51 single chip microcomputer with general learning board, because use serial communication mode, use of serial interface mode of the cape in small programs, this is the interface mode, no matter what I input area input single-chip computer haven't any responseCodePudding user response:
UARTInit outside loopCodePudding user response: