CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Delay Routines And "Time" Parameter

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Keith Ward



Joined: 09 Apr 2005
Posts: 2

View user's profile Send private message

Delay Routines And "Time" Parameter
PostPosted: Sat Apr 16, 2005 8:53 pm     Reply with quote

According to the compiler manual the delay routines will accept variable values up to 255 or constants up to 65536. Why is this and why would it make a difference?? I discovered this "feature" by accident when attempting to change a variable to values above 255 and noticed that the delay values were being truncated to acceptable values for the routine. I have never seen a function that does anything like this before. Comments? Explanations?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Sun Apr 17, 2005 12:08 am     Reply with quote

It is because that's the way CCS made it. The delay routine isn't really just C code that they include but it is generated asm code based on how you call the "magic" function.
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Sun Apr 17, 2005 9:38 am     Reply with quote

Mark is right. The answer is "just because". It is a bit screwy and a compiler warning message about wrong data type as the function argument would be helpful.

But in general, if at all possible, work out a way to NOT use the delay functions in your code. Use timers and interrupts or if a PIC is available with dedicated hardware to accomplish your goal, use that instead of bit-banging a port.

And please, please, please don't ever put a delay_ms or _us statement into an interrupt service routine.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 17, 2005 2:31 pm     Reply with quote

Quote:

I discovered this "feature" by accident when attempting to change a
variable to values above 255 and noticed that the delay values were
being truncated to acceptable values for the routine.

A possible work-around for this limitation:
http://www.ccsinfo.com/forum/viewtopic.php?t=16656
Keith Ward



Joined: 09 Apr 2005
Posts: 2

View user's profile Send private message

PostPosted: Sun Apr 17, 2005 7:30 pm     Reply with quote

Can't say I like the reason of "just because" but there is probably a good reason that someone went to the effort of making it that way. My actual use is quite simple, it's just for piezo buzzer freqs and not for acutual code timing.

Thanks all.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group