Question about order of events

void loop()
{
  TCCR2A = _BV(COM2A0) | _BV(WGM21) | _BV(WGM20);
  TCCR2B = _BV(WGM22) | _BV(CS20);
  OCR2A = B11000111; // 199, so timer2 counts from 0 to 199 (200 cycles at 16 MHz) // does the code wait until timer2 
  //counts to 199 before moving onto  the next line, or does it start the counter and then execute the next line?
  next line do something here;
}

Hi, I'm new here to the forum and to arduino. Basically my question is that above; can I start a counter and then move onto the next line of code, or does the counter count until 199 before executing "next line do something here;" ?

Many thanks

Albert

  OCR2A = B11000111; // 199, so timer2 counts from 0 to 199 (200 cycles at 16 MHz) // does the code wait until timer2

That defines the overflow value. Nothing waits for the interrupt to happen.

You should not be diddling with timer values with interrupts enabled, and you probably shouldn't be diddling with them in loop().

Thank you. I'm probably trying to run before I can walk. Basically what I need is to turn a digital pin on for 12.5 microseconds and then off and simultaneously monitor a second pin to check if it's been turned on or not. The second pin may go high before the 12.5 microseconds is up. I realize now that the code I posted turns the pin on and off continuously. how can I change it so it only pulses once? Is it as simple as leaving out this line?

TCCR2B = _BV(WGM22) | _BV(CS20);

Albert