I m using NXP89v51RD2 micro......
the oscillator frequency is 11.0593 MHz...
I want to make a delay function as user want to set it....such like for 3 sec,4 sec,8 sec etc....
can anybody help me and provide me codes for this in c language.......
and logic too..
Use Compiler and check how much time is needed to make a delay of 1 us then using time taken for one nop make the delay function for 1 us then use this function to get the desired delays.
STEP 1. FOR CRYSTAL FREQUENCY = 11.0592MHz
STEP 2. ONE MACHINE CYCLE FREQUENCY = CRYSTAL FREQUENCY/12 = 11.0592/12 = 921.6ms
STEP 3. ONE MACHINE CYCLE TIME PERIOD = 1/FREQUENCY = 1/921.6ms = 1.085us
thank for reply jayanth..
I m using keil uvision 3 as a compiler....
how can I check time needed to make delay of 1 us....
and than how I make nop function by using this.......
As I have very few knowledge about these things so it 's my request please explain it in simple way.....
My programming......
void delay(unsigned int time)
{
int a,b;
time=(time*1000*60); //as required delay in min
for(a=0;a<time;a++)
for(b=0;b<120;b++);
}
But I found almost same delay(about 1 min) for any value of time such like time=1,2,3....etc
why is this happening?
thanks for reply....
I don't know how to use interrupts and programming for this.....
Can u help me by providing codes for this or giving any idea about this.......:--(