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_us(time) command usage

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







delay_us(time) command usage
PostPosted: Sat Nov 04, 2006 3:41 pm     Reply with quote

hi,
in my program (PIC16f877 20MHz) I want to use delay_us command with a "variable", for example;

alpha=5000;
delay_us(alpha);

but you know, CCS manual says "time - a variable 0-255 or a constant 0-65535"

so for an easy solution, i wrote a "moredelay" function like this:

void moredelay(long x)
{
int kalan, bolen,i;
kalan = x%255;
bolen = x/255;
for(i=1;i<=bolen;i++)
{
delay_us(255);
}
delay_us(kalan);
}

it works, but with additional faulty delay. for example when x=0, it waits extra 2-3ms..

could you please explain how can I solve the problem... ??
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Nov 04, 2006 4:33 pm     Reply with quote

Here are two functions for a long delay with a variable parameter (16-bit).

long_delay_us():
http://www.ccsinfo.com/forum/viewtopic.php?t=16656

long_delay_ms():
http://www.ccsinfo.com/forum/viewtopic.php?t=375
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