View previous topic :: View next topic |
Author |
Message |
Freddie
Joined: 06 Sep 2003 Posts: 49
|
delay_ms() question. |
Posted: Sun Mar 05, 2006 7:26 pm |
|
|
Definition from user manual,
delay_ms(time)
Parameters:
time - a variable 0-255 or a constant 0-65535
So, in the following code, is the value I'm passing a variable or constant? If it is a variable, how can I force it to be a constant?
Code: |
#define dropoutTime 100
for(cycle=0;cycle<10;cycle++)
{
delay_ms(dropoutTime*(10-cycle));
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Mon Mar 06, 2006 9:15 am |
|
|
One bad thing about the delay() command is that it causes the PIC to just sit there, twidling it's thumbs, waiting for it to get done. I try not to use it because the PIC could be doing other things while waiting. I like to use the built in timers instead. Just have the portion, that needs the delay, in your main body and have a timer set a flag that will enable that section to continue after a certain amount of time. You can use variables as much as you want this way to adjust the delay time.
Ronald |
|
|
|