Reading a variable set in an ISR, or using millis() for time within while loop?

I am using while loop to wait for a start signal in a subroutine and I was trying to monitor how long it was sitting in the loop as it needs to break and produce a fault if there is no signal within a few seconds. I set up a timer with an overflow and set a volatile byte variable that I load an led output that is flashing in the ISR as I saw that in an example. I can monitor the status fine until I try it within a loop? Going a different route I tried to use millis() and ran into the same issue. I also tried doing a digital read in the while loop of the led output within the ISR routine. It seems not to see it turning on and off? Currently just increment a variable and if it gets to 32700 it kicks out but this in not really enough time. Could use a double long but this just seems like a lame way of doing this. Any info on best way to monitor longer blocks of time within a while loop in a subroutine would be appreciated. Thankyou.

Post your code showing the things you've tried. Use code tags.

saladman:
I set up a timer with an overflow

Why? You just record the value of millis() or micros() at the time of interest and compare against it
later.

And yes, post your code, we can't mind-read!

I had to put things back together as I had a mess. So I load to board and it seems to be working now?
I thought I had tried all the logical things to make it work but obviously I had missed something simple. I am putting the code in for anyone like me who may run into problems. Thanks

#define ledPin 8
#define Swin 3


void setup()
{
  pinMode(ledPin, OUTPUT);

pinMode(Swin, OUTPUT);


 // initialize timer1 
  cli();           // disable all interrupts
  TCCR3A = 0;      // Clean the registers
  TCCR3B = 0; 
 // OCR3A = 32767;  // set compare register to desired timer count
 // TCCR3B |= (1<<WGM12); // added this to do CTC function
  TCCR3B |= (1 << CS12) ;//| (1 << CS10); // Prescaler 1024
 TIMSK3 |= (1 << TOIE3);   // enable timer overflow interrupt
 // TIMSK3 |= (1 << OCIE3A);   // enable timer compare interrupt
 sei();             // enable all interrupts

}


ISR(TIMER3_OVF_vect)        // interrupt service routine 
//ISR(TIMER1_COMPA_VECT)
{

  digitalWrite(ledPin, digitalRead(ledPin) ^ 1);

}


void loop()
{
subx();
  
}  
void subx()
{

int whatever = 0;


  while(whatever == 0){
int readledstatus; 

readledstatus = digitalRead(ledPin);

  if ( readledstatus == 0)
{
  digitalWrite(Swin, LOW);
  delay(1000);
  
  
}
  if (readledstatus == 1)
{
  digitalWrite(Swin, HIGH);
  delay(1000);
  
   
}  
}


}

I thought I had tried all the logical things

Except
for using
Tools + Auto Format
so your
code
doesn't
look like it was
typed by a drunken monkey.

OP, this code doesn’t do what you described in your original post. The function subx() never exits. Whatever you’re trying to do, this is a pretty convoluted way of doing it. Perhaps describe again what you want to accomplish?

  while(whatever == 0){

Yes, but you never change the value of whatever inside your loop. It's a local variable in that function, so no other function (including the interrupt) can change it.

This may be what you intended. But if you really want a while loop which never exits, just write while(true)

So you want something like this?

const byte LedPin = 8;
const byte SwinPin = 3;
volatile boolean StartSignal = false;
unsigned long MaxStartTime = 5000;  // StartSignal must be set within 5 seconds
unsigned long StartTime;
void setup() {
  pinMode(LedPin, OUTPUT);
  pinMode(SwinPin, OUTPUT);
  // initialize timer1
  cli();           // disable all interrupts
  TCCR3A = 0;      // Clean the registers
  TCCR3B = (1 << CS12) ;   // Prescaler 1024
  TIMSK3 |= (1 << TOIE3);   // enable timer overflow interrupt
  sei();             // enable all interrupts
  StartTime = millis();
}
ISR(TIMER3_OVF_vect) {        // interrupt service routine
  digitalWrite(LedPin, !digitalRead(LedPin));
  StartSignal = true;
}
void loop() {
  static boolean running = false;
  // Wait for start signal from ISR
  if (!running) {
    if (StartSignal) {
      running = true;
    } else {
      if (millis() - StartTime >= MaxStartTime) {
        // ERROR: StartSignal did not get set in time
      }
    }
    return;
  }  //end if (!runing)
  // RUNNING.  Do the stuff
}

Hard to see what value the timer interrupt brings to this application.