Hi, I want to know how to generate delays using C. I am using 89c51, 11.0592 crystal.
There have been some good past threads on the subject if you search the knowledgebase. For short delays (on the order of microseconds), you can use some Keil extensions to insert NOP instructions into your code. For slightly longer delays, you'll probably want to use a timer to measure the delay. For even longer delays, where you don't want to tie up the processor while waiting, you'll need a timer tick interrupt and some sort of software timer queue structure. The timer interrupt will signal the occurrence of an event (however that is to be done in your system) and set up the timer for the next event. There's no one standard C language call that will do this for you.
the difference between 50.0 and 49.99 is about 4 uS. To achieve that precision with 12Mhz Xtal and - I assume a 12 clocker - you need be precise within 4 instruction cycles. That will require that there are no MUL or DIV instructions in your program since an itrerrupt does not interrupt an instruction in progress. Erik
Hi Erik, Thanks again for the reply, can you suggest me any other alternative to measyre frequency, cos i am going to be using mul and div instructions, cos this meter has a RPM meter as well. I repeat, i am using a 12 MHz clocker, 89c51, and am looking at .01Hz resolution. Thanks
you gan get the resolution with no problem, just not the accuracy. Erik