Two interrupts same input problem ?

Having trouble getting INT0 and INT1 to work Im trying to make a Hysteresis reader ? anyway I had it working on an atmega328p but wanted higher precision so i hooked up an ADS1115 and yes I have it working as I want but well it reads with interrupts works great except im trying to read on rising edge
and again on falling edge so i can calculate hysteresis ..It reads on rising edge but not falling edge
(Two different interrupts ) Ihave them both connected to an op amp comparator going to be battery charger at some point in time anyway any ideas on why both interrupts wont fire off same pin ?

Well...here is the code

//*************************************Begin-IncludeFiles*********************************

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <avr/interrupt.h>
#include <avr/io.h>
#include <util/delay.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads(0x48);
int16_t adc0;  // we read from the ADC, we have a sixteen bit integer as a result
LiquidCrystal_I2C lcd(0x3f,20,4);
int flag = 0;
int sensorValue=0;
float voltage=0;
//******************************End-IncludeFiles-and-Global-Varyables**********************

void setup()
{
  analogReference(DEFAULT);
  DDRD = 0b00000000;
 // lcd.begin(20,4);  // initialize the lcd added and works 
  lcd.init();       // initialize the lcd
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("HysteresisCalculator");
  delay(2000);
  lcd.clear();
  //*********************************-interrupt1**********************************************

 PORTD|=(1 << PORTD3);            // turn On the Pull-up PD3 is now an input with pull-up enabled
 EICRA|=(1 << ISC11)|(1 << ISC10); // set INT1 to trigger on rising edge
 EIMSK =(1 << INT1);              // Turns on INT1

//***********************-END-OF-INTERRUPT-2*************************************************
//*********************************-interrupt2***********************************************

 PORTD|=(1 << PORTD2);              // turn On the Pull-up PD3 is now an input with pull-up enabled
 EICRA|=(1 << ISC01)|(0 << ISC00);   // set INT0 to trigger on falling edge
 EIMSK =(1 << INT0);                // Turns on INT0

//**************************-END-OF-INTERRUPT-2***********************************************
}
void loop()
{
 
 sei(); // turn on interrupts


//***************************Flag-1*************************************************************
  if (flag == 1)
{
    adc0 = ads.readADC_SingleEnded(0);
    voltage = (adc0 * 0.1875)/1000;
    lcd.setCursor(0,0);
    lcd.print("A0=");
    lcd.print(voltage,4);
    lcd.setCursor(11,0);
    lcd.print("INT1");
    delay(500);
    flag = 0;
}
//****************************Flag-2*************************************************************
  if (flag == 2)
{
    adc0 = ads.readADC_SingleEnded(0);
    voltage = (adc0 * 0.1875)/1000;
    lcd.setCursor(0,1);
    lcd.print("A0=");
    lcd.print(voltage,4);
    lcd.setCursor(11,1);
    lcd.print("INT0");
    delay(500);
    flag = 0;
}
 
  
}//*************************END-OF-MAIN**************************************

//*************INT1-Triggers-on-Rising-Edge
ISR (INT1_vect)
{
flag = 1;
}
//*****END-OF-ISR**************

//*************INT0-Triggers-on-Falling-Edge
ISR (INT0_vect)
{
flag = 2;
}
//*****END-OF-ISR**************

It could be that the pulse you get from the device is so short that by the time you have serviced the rising edge in the loop, printing stuff to the LCD, then your 500mS delay etc. and finally reset the flag, the pulse has already gone and there is no falling edge left to detect.

I've just looked at the data sheet for the ADS1115. Depending on the mode, the rising edge of the pulse (on Alert/Rdy) signals that something is ready, but it is not clear to me what information can be derived from the falling end of the pulse.

flag should be declared as volatile.

well it cant be im just using a thermistor to trigger an op amp ? but thats a good thought it takes about 30-45
seconds to switch back after it has triggered

OK. Well the next stage is for you to post a schematic of your circuit.
If your timescales are 30 - 45 seconds, then an interrupt may not be the ideal solution for this.

yea its definitely not a timing thing the reason im using interrupts is because I need the voltage at the exact time it cuts off

i have no way of showing the circuit diagram all the simulators and schematic drawing software i found
dont have all parts ? like the ADS1115 and I2C LCD

Just draw 3 wires going into a box and label it "LCD".

Or draw the schematic by hand and take a photo. In most cases this is actually better than using a CAD program.

"...exact time it cuts off". Well, nothing can be exact. How many microseconds do you need? If 5-10 microseconds is acceptable, then a regular digitalRead() in the main loop will probably work. Just don't use delay() inside the loop.

I'd say 10 milliseconds would be fast enough

it weird i hooked up my scope to it and it has a perfect square wave form its only 2.7 volts but like I say one
interrupt is working fine INT1 ....INT0 will not fire it is set to trigger on falling edge

EIMSK =(1 << INT1);          
 EIMSK =(1 << INT0);

Both these statements should be |=

The second assignment is over writing the first.

DUDE..! you are Very wise it worked great ! thank you

i changed EIMSK = (1 << INT0); to EIMSK = 0x3 ; worked first try

I would have never thought of that ...I have posted on here a lot of times and that is the second time anyone
has ever actually got it right First try a guy helped me to read analog pins with interrupts was the first time
I don't remember what his name was might have been you cattle dog

I would have never thought of that

Maybe not, but I think that in desperation you might have gone back to standard pinMode() and attachInterrupt() syntax and all would have been well.

I'm not sure that the additional couple of microseconds latency of the arduino routine, compared to the register setting, is important for your application.

here is a copy of the code ..it works very well for someone who does not know how to calculate hysteresis even if they do know it is a good way to test your knowledge it uses a 20x4 lcd with
I2C backpack and an I2C ADC1115 ...seems to be very accurate

//*************************************Begin-IncludeFiles*********************************

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <avr/interrupt.h>
#include <avr/io.h>
#include <util/delay.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads(0x48);
int16_t adc0;  // we read from the ADC, we have a sixteen bit integer as a result
LiquidCrystal_I2C lcd(0x3f,20,4);
float V1,V2;
float Hyst=0;
int flag = 0;
int sensorValue=0;
float voltage=0;
//******************************End-IncludeFiles-and-Global-Varyables**********************

void setup()
{
  analogReference(DEFAULT);
  DDRD = 0b00000000;
 // lcd.begin(20,4);  // initialize the lcd added and works 
  lcd.init();       // initialize the lcd
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("HysteresisCalculator");
  delay(2000);
  lcd.clear();
  //*********************************-interrupt1**********************************************--does-not-trigger

 PORTD|=(1 << PORTD3);            // turn On the Pull-up PD3 is now an input with pull-up enabled
 EICRA|=(1 << ISC11)|(1 << ISC10); // set INT1 to trigger on rising edge
 EIMSK |=(1 << INT1);              // Turns on INT1

//***********************-END-OF-INTERRUPT-1*************************************************
//*********************************-interrupt2***********************************************

// PORTD|=(1 << PORTD2);              // turn On the Pull-up PD3 is now an input with pull-up enabled
 EICRA|=(1 << ISC01)|(0 << ISC00);   // set INT0 to trigger on falling edge
 EIMSK |=(1 << INT0);                // Turns on INT0

//**************************-END-OF-INTERRUPT-2***********************************************
}
void loop()
{
 
 sei(); // turn on interrupts


//***************************Flag-1*************************************************************
  if (flag == 1)
{
    
    adc0 = ads.readADC_SingleEnded(0);
    voltage = (adc0 * 0.1875)/1000;
     V1 =voltage;
    lcd.setCursor(0,0);
    lcd.print("HVT=");
    lcd.print(voltage,4);
    lcd.setCursor(11,0);
    lcd.print("INT1");
    delay(500);
    flag = 0;
}
//****************************Flag-2*************************************************************
  if (flag == 2)
{
    adc0 = ads.readADC_SingleEnded(0);
    voltage = (adc0 * 0.1875)/1000;
     V2=voltage;
    if(V2>V1){Hyst=V2-V1;}
    else{Hyst=V1-V2;}
    lcd.setCursor(0,1);
    lcd.print("LVT=");
    lcd.print(voltage,4);
    lcd.setCursor(11,1);
    lcd.print("INT0");
    lcd.setCursor(0,2);
    lcd.print("Hyst= ");
    lcd.print(Hyst,4);
    delay(500);
    flag = 0;
    
}
 
  
}//*************************END-OF-MAIN**************************************

//*************INT1-Triggers-on-Rising-Edge
ISR (INT1_vect)
{
flag = 1;
}
//*****END-OF-ISR**************

//*************INT0-Triggers-on-Falling-Edge
ISR (INT0_vect)
{
flag = 2;
}
//*****END-OF-ISR**************

both interrupt pins connect to output pin of op amp
it is a simple circuit