void MSDelay(unsigned int value)
{
unsigned int x, y;
for(x=0;x<1275;x++)
for(y=0;y<value;y++);
}
To get the delay value from user, what is your application??
try this with all reference book
Code:void MSDelay(unsigned int value) { unsigned int x, y; for(x=0;x<1275;x++) for(y=0;y<value;y++); }
try this with all reference book
Code:void MSDelay(unsigned int value) { unsigned int x, y; for(x=0;x<1275;x++) for(y=0;y<value;y++); }
void TimeDelay (int mS)
{
unsigned int a ;
unsigned char b ;
for(a = 0 ; a < mS ; a++)
{
for (b = 0 ; b < 190 ; b++) /* for crystal 11.0592 Mhz delay is 1 mSec. */
{
_nop_();
_nop_();
}
}
}
ok then try this
Code:void TimeDelay (int mS) { unsigned int a ; unsigned char b ; for(a = 0 ; a < mS ; a++) { for (b = 0 ; b < 190 ; b++) /* for crystal 11.0592 Mhz delay is 1 mSec. */ { _nop_(); _nop_(); } } }
and reply me .
What is the possible range of the delay durations do you require? Minutes, hours, days, weeks, etc?
Utilizing C loop structures, like the MSDelay() routine, to generate a delay is typically the least desirable of methods.
BigDog
void delay(unsigned int time) // SUB FUNCTIONS
{
unsigned char pause, i = 0; //DECLARE PAUSE AS UNSIGNED CHAR
short int temp = 0;
temp = time;
for (i = 0; i < 4; i++) {
time = temp;
while (time > 0) //LOOP UNTIL TIME IS GREATER THAN ZERO
{
pause = 112; //INITIALIZE PAUSE TO 255
while (pause--); //DECREMENT PAUSE UNTIL IT BECOMES ZERO
time--; //DECREMENT TIME AND LOOP BACK UNTIL IT BECOMES ZERO
}
}
}
I want its in minute and also for sometime its in hour.
void MSDelay(unsigned int value)
{
unsigned int x, y;
for(x=0;x<1275;x++)
for(y=0;y<value;y++);
}
try to post your full code with port setting . and if post #7 u apply then what's the result ?
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 #include<reg52.h> #include<stdio.h> sbit VALVE_pin = P2^0; //Defining VALVE PIN void MSDelay(unsigned int); //Function prototype declaration void main (void) { VALVE_pin = 0; //Making VALVE pin output while(1) //infinite loop { VALVE_pin = 1; //VALVE ON MSDelay(25000); //Delay VALVE_pin = 0; //VALVE OFF MSDelay(10000); } } void MSDelay(unsigned int k) { unsigned int i,j; for(i=0; i<k; i++) for(j=0; j<2556; j++) { _nop_(); } }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?