How can one generate a precise time delay wihtout using the timers and using only the software loops.
Hello you can generate delays using the following code HERE:MOV R1,#F0H DJNZ R1,HERE i hope it can generate the precise time delays , dont forget to calculate the machine cycles. regards john
See here: http://www.keil.com/forum/docs/thread1573.asp Implementing delays with program loops has, of course, many disadvantages. However, if you have no choice then it is simply a matter of adding up the instructions cylces that you need to "waste". The results are generally hightly non-portable.
do not fall tinto the trap of doing this in C. There is no requirement that a C compiler maintain the time when ANYTHING changes. Erik
I make delays (usually) by having (or sacraficing) a timer that generates a mili second interupt. Most of my programs have a mili-second timer (really a counter) in maintained software. Sometimes I create a variable and increment it in the ISR, poll it in the main loop, and clear it when it reaches the target value. This works well enough for my apps where +- 1mS (or even more) is trivial. How precise you need to be for you app? Andy
PS - I go through all this just because I hate using busy waiting techniques in embedded software. While the uC is in this state, it's doing nothing else. Andy
Don't forget - if you want precise delays, you will need to disable interrupts.
I just said: "if you want precise delays, you will need to disable interrupts" What I should've said is: "if you want precise precise delays using software loops, you will need to disable interrupts"