Home > Back-end >  51 single chip microcomputer timer 0 affect the normal work of the timer 1, how to solve?
51 single chip microcomputer timer 0 affect the normal work of the timer 1, how to solve?

Time:11-20

expected effect:
On the PC with serial debugging assistant send microcontroller one character at a time, single-chip microcomputer automatically send a "123" to the PC,

code:
 # include 

Unsigned char flag, a;

Void main ()
{
TMOD=0 x21;
TH1=0 XFD;
TL1=0 XFD;
TH0=0 xfe;
TL0=0 x33;
TR1=1;
REN=1;
SM0=0;
The SM1=1;
EA=1;
ES=1;
ET0=1;
TR0=1;

While (1)
{
If (flag==1)
{
ES=0;
flag=0;
SBUF='1'.
while(! TI);
TI=0;
SBUF='2'.
while(! TI);
TI=0;
SBUF='3';
while(! TI);
TI=0;
ES=1;
}
}
}

Void ser () interrupt 4
{
RI=0;
A=SBUF;
flag=1;
}


problem phenomenon:
After power on, PC haven't send any character, single-chip computer began to constantly send "123" to the PC,
But if the ET0=1; Or TR0=1; Code (18 ~ 19) statement annotations, can work normally,


if you can help solve, thank you very much!
  • Related