Home > other >  I want to realize through the computer input three Numbers to make the 51 single-chip digital tube d
I want to realize through the computer input three Numbers to make the 51 single-chip digital tube d

Time:11-15

#include The function of the//program is through the computer to the microcontroller sends a decimal
#include//number, let the microcontroller on the digital tube display
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 response

CodePudding user response:

UARTInit outside loop

CodePudding user response:

refer to the second floor zgl7903 response:
UARTInit outside loop

But still didn't respond

CodePudding user response:

Num=SBUF - '0';

CodePudding user response:

Don't put a delay in the interrupt

CodePudding user response:

Did you turn the usb serial port or directly using a serial port to a serial port? Program to write single chip microcomputer hardware and driver first must not be less, another is your system to support a serial port driver? Serial port driver version is low also not line, again from the website to download driver, the hope can help you, window 7 system doesn't work, try a Windows XP system try

CodePudding user response:

Serial port initialization sequence, general really didn't like you to write, the basic are configured before they can make, you are the first to run after the timer configuration, may the timer does not support runtime configuration, so is the work in the default mode, the baud rate is very low, and PC is 9600, assuming that single chip computer 100, the actual baud rate you didn't get a 96 single chip microcomputer, actually not necessarily can receive

CodePudding user response:

The original poster in front of the serial port communication debugging finished dynamic display of digital tube?

CodePudding user response:

Lz, share

CodePudding user response:

You this... , primary school students! ? Initialize the serial port on the while (1) outside, a serial port receiving interrupt receiving data, the data processing and display, in the while (1) to do it

CodePudding user response:


Void UART interrupt ()
4{
If (RI)
{
Num=SBUF;
RI=0;//software reset accepts mark a
}
The display (num);//the interrupt generally only responsible for do simple receiving data, display in the main loop
}
Void main ()
{
//need to initialize the action on here
While (1)
{
UARTInit ();//in the loop, the change of action, or to monitor the status, the initialization error on this
}
}

Lz need good good study day day up, come on

CodePudding user response:

11 references worldy response:
void UART interrupt ()
4{
If (RI)
{
Num=SBUF;
RI=0;//software reset accepts mark a
}
The display (num);//the interrupt generally only responsible for do simple receiving data, display in the main loop
}
Void main ()
{
//need to initialize the action on here
While (1)
{
UARTInit ();//in the loop, the change of action, or to monitor the status, the initialization error on this
}
}

Lz need good good study day day up, come on

Thank you

CodePudding user response:

refer to the eighth floor yishumei response:
the building in front of the serial port communication debugging finished dynamic display of digital tube?

Complete the, I the digital tube display is to use dynamic program

CodePudding user response:

Lz, share
  • Related