Current location - Quotes Website - Team slogan - 5 1 MCU timing and serial port conflict?
5 1 MCU timing and serial port conflict?
T0 interrupts are too frequent, because at the same level, T0 takes precedence, so the interrupts are always preempted and the serial port is marginalized. Modify the program:

Invalid? Timer initialization ()

{?

TMOD = 0x 22;

SCON = 0x 50;

th 1 = 0x FD;

TL 1 = 0x FD;

tr 1 = 1;

TH0 = 246

TL0 = 246

ET0 = 1;

TR0 = 1;

ES = 1;

EA = 1;

PS = 1; ?

}?

Invalid? Timer 0_int ()? Interrupt? 1?

{

time++;

If (time & lt50)//count is the duty ratio.

{

PWM = 1; //Output high level

}

Or what?

PWM = 0;

If (time & gt= 100)

{

Time = 0;

}

}

Invalid? ser()? Interrupt? four

{

What if? (day)

{

RI = 0;

re _ buf[counter]= SBUF;

if(counter = = 0 & amp; & ampRe_buf[0]! =0x55)? Return; ? //No.0 data is not a frame header.

counter++; ?

if(counter== 1 1)? //Received 1 1 data.

{?

Counter = 0; ? //Reassign the value and prepare to receive the next frame of data?

switch(Re_buf? [ 1])

{

Case? 0x53:?

UC return[0]= Re _ buf[2];

UC return[ 1]= Re _ buf[3];

UC return[2]= Re _ buf[4];

UC return[3]= Re _ buf[5];

UC return[4]= Re _ buf[6];

UC return[5]= Re _ buf[7];

Break;

}?

}

}

Vax? =? ((short) (UC strangles [1] < & lt8|? UC return[0]))/32768.0 * 180;

if(Vax & gt; 0)

{

x = 1;

xx = 0;

}

Or what? if(Vax & lt; =0)

{

x = 0;

xx = 1;

}

}