Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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;
  }
}
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top