hello all
i want to introduce delay in program in microsecond range. can any one give me some examples for lpc17xx.
Thanks in advance.
If you can set up the timer and reach the polling loop within 72 clock cycles, then you can use the timer method.
The issue here is if you can guarantee that your C compiler will always manage to produce code that reaches the polling loop within 72 clock cycles. Next thing is that you don't know what instructions the C compiler uses for the polling loop, so you don't know if you may get 1, 2, 3, 4, 5, ... clock cycles worst-case error because of where you are in the loop.
For very short delays using the timer method, it's best to write the code in assembler.
About 9MHz instead of 18MHz - I don't have an explanation right now, without looking closer at the processor. Maybe the example was originally written with the peripherial clock setting 11 instead of 00, which is 1/8 division. The documentation seems to indicate that the counter should be updated every PCLK when PR=0, so 18000000/1000-1 would have seen a more logical.