waiting for two inputs

how can i say wait for both input values to change before I can have my other code compare them?

I just want to be able to see if both inputs will change, because I am already continuously changing them but i want to compare only the values I haven't compared yet, for example i dont want to compare the old t1 with the new t2, and I want to know how to poll the inputs if maybe that would work?

void loop() { 
  
  if (t2 == t1)
  {
    OCR2A = 0;
    OCR2B = 0;
  }
  //compare time that one signal goes high to time the other signal goes high
  else if(t2 > t1)
    {
    OCR2A = (t2-t1) ; //output PWM based on phase difference on pin 9
    OCR2B = 0;
    }
  else if(t2 < t1)
    {
    OCR2B = (t2-t1);    //output PWM on pin 10
    OCR2A = 0;
    }}

When you post code post all it it please.

Why are you messing about with the timers, it seems nothing related to your question.

Do you know about a compound if statement?

if( this == that && then == theOther)

The && is a logic AND and both statements have to be true.

when I use the logic AND gates it doesn't work properly, the old inputs are still stored

when I use the logic AND gates

Nobody mentioned AND gates. These are AND gates

BUT people did mention posting ALL your code which you have still not done.

sorry for that

this is the code I'm using now:

#include <avr/io.h>
#include <avr/interrupt.h>

void setup() {
  // put your setup code here, to run once:
  noInterrupts();
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM20);
  TCCR2B = _BV(CS22);
  OCR2A = 0;
  OCR2B = 0;
  TCNT2 = 0;
  interrupts();

  attachInterrupt(digitalPinToInterrupt(2), t1_ISR, RISING);     //enable interrupt service routines on pins 2 and 3
  attachInterrupt(digitalPinToInterrupt(3), t2_ISR, RISING);
}

volatile unsigned int t1;
volatile unsigned int t2;
volatile unsigned int oldt1 = 0;
volatile unsigned int oldt2 = 0;

void loop() {
  // put your main code here, to run repeatedly:
  while((t1 != oldt1) && (t2 != oldt2)){
    if(t1<t2){
      OCR2A = t2-t1;   //duty cycle   50%
      OCR2B = 0;
    }
    else if(t2<t1){
      OCR2B = t1-t2;
      OCR2A = 0;
    }
  }
  oldt1 = t1;
  oldt2 = t2;
}

void t1_ISR(){
  t1 = TCNT2;
}

void t2_ISR(){
  t2 = TCNT2;
}

Thanks but I have no idea what this code is trying to do and more specifically why it is trying to do it. Also why are you messing with the timer's registers when it would seem doing a simple analogWrite would do the job.

However their are things you are doing wrong with handling the interrupts.

The variables you are using are int types and this is an 8 bit processor. Therefore any operations using them can have the rug pulled out from underneath them by the interrupt service routine changing the value while the main loop accesses one byte of the int and then the next byte of the newly changed int. As their is no need for them to be ints change them to byte type.

I am trying to output a pwm signal to one of two output pins depending on whether the delay is leading or lagging and the duty cycle of the pwm should reflect the time delay of the two input square waves, we are reading the phase shift basically so it can directly go to the Voltage controlled oscillator after we filter it and use a summing amplifier