Delay Using Busy Loop

Easy C Control
Solve this problem

Implement a blocking delay loop using busy-waiting. Used for timing LED toggles in lightweight bare-metal systems without timers.

Constraints

  • Argument is number of iterations.
  • Use volatile to prevent optimization.
  • Pure busy wait with decrementing loop.
  • Must compile on ARM or x86.
Starter codeC
1void delay(volatile unsigned int n);