interrupts

Status
Not open for further replies.

aamirkhan

New Member
hi
i am writting a program to recieve data throuth serial port (UART) of
AT89S51 microcontroller.Using the interrupts i have wriiten the ISR as

void serial_ISR () interrupt 4 using 2
{
if(RI == 1)
{
led = on;
RI=0;
}}
the interrupt is occuring but the led do not get ON
if i write ISR like this

void serial_ISR () interrupt 4 using 2
{
led = on;
if(RI == 1)
{
RI=0;}
}
now led gets on
this means it is getting some thing but why RI == 1; is not working
do the recieve flag automatically gets clear
 
I posted a reply very early this AM but it is gone along with several others.

First use the # tool to place code tags around your code to make it readable.
For testing I would use 3 LEDs or breakpoints if you have run control. The serial interrupt can be set by the RX or TX. Check for both and neither which in theory should not happen. Check anyway.

Code:
void serial_ISR () interrupt 4 using 2
{
  if(RI == 1)
  {
    RX_led = on; 
    RI=0;
  }
  if(TI == 1)
  {
    TX_led = on; 
    TI=0;
  }
  else
  {
    ERROR_led = ON;
    TI=0; 
    RI=0;
  }
}
 
@colin mac (and everyone)
When you see a duplicate thread please post in the one that already has replies. Let the other one die.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…