cheenu02
Junior Member level 3
hi,
I am using external interrupt 1 in p89v51rd2 for operating a pump through the dispenser switch.I connect the dispenser switch with PIN 3.3 .when I press the dispenser switch the pump doesn't get turn on sometimes.Please check My ISR routine below
void timer_init()
{
TMOD |= 0x01; //Intialize Timer 0
TL0 = 0xff;
TH0 = 0xFf;
// IEN0=0x87; // Enable Timer 0 interrupt
TR0 = 1; //Start Timer 0
ET0 = 1;
}
void desable_timer0()
{
ET0 = 0; // Desable timer0 interrupt
TR0 = 0; // Stop Timer 0
}
//ISR to check Dispenser switch is pressed
void check_dispensor_sw() interrupt 2
{
if (disp_solenoid == 0)
{
timer_init(); // Enable timer for checking disp_solenoid state
pump = 1;
}
return;
}
void timer_isr()interrupt 1
{
if (disp_solenoid == 1)
{
desable_timer0();
pump = 0; // Switch off the pump
}
return;
}
I am using external interrupt 1 in p89v51rd2 for operating a pump through the dispenser switch.I connect the dispenser switch with PIN 3.3 .when I press the dispenser switch the pump doesn't get turn on sometimes.Please check My ISR routine below
void timer_init()
{
TMOD |= 0x01; //Intialize Timer 0
TL0 = 0xff;
TH0 = 0xFf;
// IEN0=0x87; // Enable Timer 0 interrupt
TR0 = 1; //Start Timer 0
ET0 = 1;
}
void desable_timer0()
{
ET0 = 0; // Desable timer0 interrupt
TR0 = 0; // Stop Timer 0
}
//ISR to check Dispenser switch is pressed
void check_dispensor_sw() interrupt 2
{
if (disp_solenoid == 0)
{
timer_init(); // Enable timer for checking disp_solenoid state
pump = 1;
}
return;
}
void timer_isr()interrupt 1
{
if (disp_solenoid == 1)
{
desable_timer0();
pump = 0; // Switch off the pump
}
return;
}