Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/28/05 14:52
Modified:
  03/28/05 15:04

Read: times


 
#90543 - Serial interrupt problem
I am using Keil 7.0 demo version.
Now I am trying to write a code which using serial interrupt to send and receive URAT data. However, I find my code not work at all.
Moreover, I can using Polling method to send and receive data, it seems that my circuit is no problem.
My code is as shown in the following, would you mind give some comment to me?
Thank you in advance!
////////////////////////////////////////////////////////////////

#include <AT89x51.H>

unsigned char ucTemp=0;

void delay(int x); //soft delay function

void main()
{ P1=0;
TMOD=0x20; //serial port init
TH1=-03;
TR1=1;
SCON=0x50;

while(1)
{
delay(1000);
TI=1;
}


}

void serial_int(void) interrupt 4{

if (RI){ //read data
RI=0;
ucTemp=SBUF;
}

if (TI){ //send data
TI=0;
SBUF=ucTemp;
}

}

List of 4 messages in thread
TopicAuthorDate
Serial interrupt problem            01/01/70 00:00      
   Corrected code            01/01/70 00:00      
      Working interrupt-driven Serial Code            01/01/70 00:00      
   Thank Andy            01/01/70 00:00      

Back to Subject List