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()

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



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

delay_us()
PostPosted: Wed Nov 23, 2005 9:38 am     Reply with quote

Hi Everybody,

In my application I use delay_us(9000) to have an delay of 9ms. And Work right.

I change so:

Quote:

int16 m;

m=9000; // 0x2328
delay_us(m);


In this case the delay is not 9ms but only 45us. I verified so with oscilloscope in debug mode.

My compiler Version is. 3.235 with PIC16F876A

what are you think about?
drh



Joined: 12 Jul 2004
Posts: 192
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Wed Nov 23, 2005 9:57 am     Reply with quote

I think you should read the compilor manual. You can use DELAY_US() with a constant up to 65535 OR a variable up to 255. That's why delay_us(9000) worked and delay_us(m) did not.
_________________
David
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Wed Nov 23, 2005 10:00 am     Reply with quote

Is there any way to use 16 bit variable in delay_us() ?

I need the maximal resolution.

Regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 23, 2005 10:08 am     Reply with quote

http://www.ccsinfo.com/forum/viewtopic.php?t=16656&highlight=longdelayus
drh



Joined: 12 Jul 2004
Posts: 192
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Wed Nov 23, 2005 10:15 am     Reply with quote

Here's one way.

Code:

int8   i;
int8   resolution;

resolution = 100; // adjust this number

for (i = 90;i > 0;i--)
   delay_us(resolution);


Adjust 'resolution' to compensate for the time it takes
to execute the for loop.
_________________
David
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Wed Nov 23, 2005 10:29 am     Reply with quote

Thanks for support,

I decided to use Timer1 whith his 16 bits of resolution. After reset it I stay in loop till became the same or more than my variable.

By the way, in other routine I use timer1 to mesure frequency of some waves.

Regards,
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