View previous topic :: View next topic |
Author |
Message |
eyewonder300
Joined: 09 Jun 2004 Posts: 52
|
Delay_us() variable greater than 255? |
Posted: Tue Nov 16, 2010 2:06 pm |
|
|
My code needs to make calculations for delays that are more than the 255 allowed when using a variable.
Is there any (easy) way to have my program make the calculation, then have that multi-thousand uSec delay?
Cheers,
Steve |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Nov 16, 2010 2:24 pm |
|
|
I'm not sure what you're asking for. Do you have an older version of the
compiler (vs. 3.xxx) that doesn't support variable delays larger than 255,
and you need a work-around ? Or, are you asking for some way to
convert usec delays into milliseconds ? Are you asking for some
alternative delay method ? |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Tue Nov 16, 2010 2:26 pm |
|
|
Use two variables one under 255 for the delay and the other to control the number of times delay is called from within a loop.
Alternatively delay will take a constant bigger than 255 so if you can accept a certain graininess use one big delay several times in your loop. |
|
|
eyewonder300
Joined: 09 Jun 2004 Posts: 52
|
Clarificaiton |
Posted: Tue Nov 16, 2010 2:39 pm |
|
|
The compiler I am using is 4.069. I have been using an old manual that says the range of a variable that could be passed is 0-255, and that a constant could be up to 65535.
What my code does is calculate a delay - ex 6666uSec, in an int16 variable 'new_delay'. What I want is to be able to do is have the program make that calculation, then execute a 'delay_us(new_delay)' for a 6,666uSec delay.
I did not try that, as my old manual indicated that it would not work.
Does my current compiler do what I want?
Thanks,
Steve |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
eyewonder300
Joined: 09 Jun 2004 Posts: 52
|
Non-problem solved |
Posted: Tue Nov 16, 2010 2:54 pm |
|
|
Thanks, PCM et al. Looking at a much newer manual told me that I could do exactly what I wanted.
Cheers,
Steve |
|
|
|