hello all
i want to introduce delay in program in microsecond range. can any one give me some examples for lpc17xx.
Thanks in advance.
it means i can't use timer method for 1 microsecond delay?
One more thing in the timer example they have mentioned CCLK = 72 MHz
In the system_lpc17xx.c file PCLKSEL0 have been set as 0x00000000 i.e. peripheral clock selection for timer 0 will be CCLK/4 72 / 4= 18MHz
But the counter value have been set according to 9MHz.
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.