Content originally posted in LPCWare by wmues on Sun Feb 08 06:00:16 MST 2015
Even if "i" is declared volatile, the compiler is allowed to delete the empty loop if "i" is not global visible.
Even worse: the 0,,,999 loop may execute in less than 100us.
The only valid solution is to to implement the udelay() function.
Every programmer using a for() loop for delays should be beaten.
regards
Wolfgang