cancel
Showing results for 
Search instead for 
Did you mean: 

Why my uart2 make program slowly?

woodhuang
Associate
Posted on February 23, 2006 at 04:11

Why my uart2 make program slowly?

1 REPLY 1
woodhuang
Associate
Posted on May 17, 2011 at 12:10

My Uart2 initialize as following:

void Init_ComPort2()

{

EA=0;

T2MOD=0;

T2CON=0x30;

TH2 =0xff;TL2 =0xDC; //T2 9600b/s 11.0592MHz

RCAP2H=0xff;RCAP2L=0xDC; //T2 9600b/s 11.0592MHz

ET2=0; //disable T2 interrupt

TR2=0;

SCON2 =0x50;

PCON |=0x0c; //Used T2

IEA &=0xef; //Disable Uart2 interrupt

TR2=1;

EA=1; //CPU interrupt enabled

}

But,At main program ,when I use

IEA |=0x10; //ES2=1 Enable Uart2 interrupt

to Enable Uart2 interrupt, I find the all program run very slowly!

The interrupt program as:

void Com2Receive() interrupt 9 using 3

{

unsigned char ch;

if (SCON2& 0x01==0x01) //RI2=1

{

ch=SBUF2;

SCON2 &= 0xFE; //RI2 = 0;

IEA &= 0xef; //ES2=0

switch(ch){

case 0xDD:

...

break;

case 0xDE:

...

break;

default:

break;

}

IEA |=0x10; //ES2=1

}

}

And I find the interrupt program always run when I debug the main prigram.

When I use Uart0 ,everything is oK!!!

Why?