Joined: 01 Oct 2003 Posts: 172 Location: Punta Gorda, Florida USA
Question about using constants isnside delay_func()
Posted: Wed Mar 10, 2004 4:52 pm
I have been trying getting around the fact that built in timing functions like delay_us, delay_(ms) or delay_cycles can only use an 8 bit unsigned variable or a constant up to 32768. I need to be able to adjust a timing sequence at runtime to a value that is larger than a byte and cannot use conditional statements such as IF or SWITCH because of their execution timing latency. One thing I thought I could do is generate various #defines and then plug them in before I execute my routines.
The basis of my question; is if you can use a constant inside these timing routines why wont the following work???
#define LongTime 23465
delay_cycles(LongTime);
It should work?? isn't the number 23465 placed in place of LongTime?
but the compiler gives me an error:
"Expression Must be a constant or simple variable"
Any help or guidance would be appreciated
cbarberis
Joined: 01 Oct 2003 Posts: 172 Location: Punta Gorda, Florida USA
Never Mind,, I just answered my own silly question
Posted: Wed Mar 10, 2004 5:00 pm
The fact is that delay_cycle() only uses a numerical constant or variable from 0 to 255 unlike the other functions, where if you use the #define it works OK
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum