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

interrupt problems with at89c51

i write a s/w for at89c51 which i use interrupts within. the code works fine in the simulator of keil but when i program it to the microcontroller the program doesn't work and the output doesn't change.

this is a test program that i wrote when i realized that the problem is from the interrupts. this code works fine when i comment the interrupt portion i.e. all that the program does that it toggles port 2. but when i use the interrupts the program doesn't run and all the outputs are fixed with no change.

#include <REGX52.H>



void Timer0_ISR (void) interrupt 1 // the smaller sample subroutine
{

	P1 ^= 0xff;
	//P2 ^= 0xff;
	P3 ^= 0xff;

}
void main(void)

{char x=0;

TMOD = 0x22; // configure timer 0 and timer 1 to run in mode 2
TH0 = 0xff - 70;
TL0 = TH0;
ET0 =1;
TR0 = 1;
EA =1;
//TR1 = 1;

P0 = 0;
P1 = 0xAA;
P2 = 0xAA;
while (1)
	{
P2 ^= 0xff;
//x++;
	}

}


thank you for your help

0