user88904: i just experimented with the timing accuracy of my Arduino Uno R3 using this code:
unsigned long beginTime;
unsigned long endTime;


void setup() {
  Serial.begin(9600); // open a serial port
}

void loop() {
  beginTime = micros();
  delayMicroseconds(200);
  endTime = micros();
  delay(500);
  Serial.println(endTime-beginTime);
  delay(500);
}

The results I got are (just an excerpt):
200
204
200
200
204
204
204
200
212
208
212
204
204

I tried to understand this behavior, read this link Can I make delayMicroseconds more accurate?.
Due to the timing of micros (4 µs) I would understand values between 200 and 208. But why do I get occasional values of 212 microseconds? I'm kinda curious, since I bought the Arduino because of bare-metal programming and bounded execution times.

user42015: The Arduino core uses hardware Timer0 with its ISR (Interrupt Service Routine) for timekeeping. While delayMicroseconds() directly uses the value of the hardware timer, delay() and millis() are handled by the ISR. It will be called regularly.
If the ISR is getting executed during your measurement, then the execution time of the ISR will add to the execution time of your measured code. Thus you get a higher count occasionally.
To prevent this you can either deactivate all interrupts (via noInterrupts()) or deactivate this specific interrupt, either by stopping Timer0:
TCCR0B &= ~( (1 << CS02) | (1 << CS01) | (1 << CS00) );

or by letting the timer run, but deactivating its interrupts:
TIMSK0 = 0;

For details about this have a look at the datasheet of the Atmega328p, which is the microcontroller on the Arduino Uno.

88904: <p>i just experimented with the timing accuracy of my Arduino Uno R3 using this code:</p>
<pre><code>unsigned long beginTime;
unsigned long endTime;


void setup() {
  Serial.begin(9600); // open a serial port
}

void loop() {
  beginTime = micros();
  delayMicroseconds(200);
  endTime = micros();
  delay(500);
  Serial.println(endTime-beginTime);
  delay(500);
}
</code></pre>
<p>The results I got are (just an excerpt):</p>
<pre><code>200
204
200
200
204
204
204
200
212
208
212
204
204
</code></pre>
<p>I tried to understand this behavior, read this link <a href="https://arduino.stackexchange.com/questions/37387/can-i-make-delaymicroseconds-more-accurate">Can I make delayMicroseconds more accurate?</a>.</p>
<p>Due to the timing of <code>micros</code> (4 µs) I would understand values between 200 and 208. <strong>But why do I get occasional values of 212 microseconds?</strong> I'm kinda curious, since I bought the Arduino because of bare-metal programming and bounded execution times.</p>
 42015: <p>The Arduino core uses hardware Timer0 with its ISR (Interrupt Service Routine) for timekeeping. While <code>delayMicroseconds()</code> directly uses the value of the hardware timer, <code>delay()</code> and <code>millis()</code> are handled by the ISR. It will be called regularly.</p>
<p>If the ISR is getting executed during your measurement, then the execution time of the ISR will add to the execution time of your measured code. Thus you get a higher count occasionally.</p>
<p>To prevent this you can either deactivate all interrupts (via <code>noInterrupts()</code>) or deactivate this specific interrupt, either by stopping Timer0:</p>
<pre><code>TCCR0B &amp;= ~( (1 &lt;&lt; CS02) | (1 &lt;&lt; CS01) | (1 &lt;&lt; CS00) );
</code></pre>
<p>or by letting the timer run, but deactivating its interrupts:</p>
<pre><code>TIMSK0 = 0;
</code></pre>
<p>For details about this have a look at the <a href="https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf" rel="nofollow noreferrer">datasheet of the Atmega328p</a>, which is the microcontroller on the Arduino Uno.</p>
