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 CCS Technical Support

Delay Problems

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



Joined: 13 Sep 2007
Posts: 14

View user's profile Send private message

Delay Problems
PostPosted: Wed Oct 03, 2007 7:36 am     Reply with quote

Hi all, i have a small problem with delay_ms() and delay_us() functions. I`m trying to control some servomotors with this functions and i need something like "delay_ms(x)" for a smoother controll in which "x" is a variable that increments and decrements.BUT the problem is that function delay_ms() doesn`t support a variable like that(simply don`t work). I tried to make my own delay functions :
Code:

void delay_u(long int u){
      long int i;
                     for(i=0;i<u;i++){
                        delay_cycles(5);     // 20Mhz = 200ns *5 =1us
                           }
                    }
void delay_m(long int m){
      long int j;
                     for(j=0;j<m;j++){
                        delay_u(1000);
                     }
                  }

this doesn`t work either.
I`m using a 20Mhz crystal and CCS versions 3.203 or 3.22
Can somebody help me please???

Many thanx,
Vodka
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 03, 2007 7:58 am     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&start=1

long_delay_ms():
http://www.ccsinfo.com/forum/viewtopic.php?t=375&start=1


You only need these functions if you have vs. 2.xxx or 3.xxx of the
compiler. In version 4, this feature is included in the delay_us() and
delay_ms() functions.
Vodka



Joined: 13 Sep 2007
Posts: 14

View user's profile Send private message

PostPosted: Wed Oct 03, 2007 11:12 am     Reply with quote

Yes indeed it works, very silly of me Embarassed .
Thanks again PCM programmer very much
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