how to use delay in c
First of all, the question is how precise you delay should be?
If not then you can just use a for loop and just experience with trial and error what the loop number should be. Or you can calculate from the ASM code to which the C compiles to (opcode).
You may also use the delay function if your library supports it.
In case you need a very fix delay time, than the best is to use timer interrupt as suryakant already proposed. The only thing I would like to add, that you need a variable (semaphore) in the subrpogram where the delay is needed, and you check its value in a while loop. From the interrupt, when the time is passed, you change the value of this semaphore. Thus the precision is within 10-20 usec (time needed to enter to timer interrupt, decremenet the SW counter, check whether is zero, if yes change the semaphore and exit from interrupt + chack the semaphore in the program).
Belsugului
Belsugului