This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Time Delay between interrupts

24 Oct 2006 12:40 Time Delay between interrupts

--------------------------------------------------------------------------------

Hello friends,
i'm trying to make a very simple program in which i'm feeding two signals (basically frequency,square waves) to at89c51 uC to measure time difference between them(one on INT0 and other on INT1 ), but i'm unable to get correct value. I've tried everything, can't understand what mistake i'm making. I'm sending my program (done in Keil c51) along with. someone please help me to find out my mistake.

Thank you friends.

int timer;

void Int0 (void) interrupt 0
{
TH0=0x00;
TL0=0x00;
TR0=1;
EX0=0;
EX1=1;

}

void Int1(void) interrupt 2
{

TR0=0;
EX1=0;

timer = TH0*256 + TL0;

TH0=0x00;
TL0=0x00;

}





void main(){


P3=0x0C;

lcd_init();


EA = 1;
TMOD = (TMOD & 0xF0) | 0x01; /* Set T/C0 Mode */
ET0 = 1; /* Enable Timer 0 Interrupts */
TR0 = 0;

IT0 = 1;
EX0 = 1;
IT1 = 1;
EX1 = 0;


TH0=0x00;
TL0=0x00;

while(1)
{


//timer value on lcd


}

0