Content originally posted in LPCWare by vtw.433e on Fri Apr 15 01:10:45 MST 2016
This code will wait for different period if built with different levels of optimization, different compilers or even different versions of the same compiler. It relies on assumption of the code that is generated and the specific clock frequency and memory characteristics of the processor it is running on. In other words, it does not wait for a specific number of micro seconds in any meaningful or reliable way.
The only reliably way to (busy) wait for a period of time is to use one of the timers and to read the timer value in a loop, and checking for the desired period to have elapsed. LPCOpen uses this method - just look in the appropriate version for your chip.