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

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Feb 04, 2007 12:22 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
ice



Joined: 30 May 2005
Posts: 10
Location: India

View user's profile Send private message Visit poster's website

Thank you
PostPosted: Sun Feb 04, 2007 1:12 pm     Reply with quote

Thank you for your help,PCM.
It now works.

My servo update in now at 70Hz ,I 'm not able to go lower than that(RTCC_DIV_256).It's slow, but it gets it's position right.


In case anyone finds it useful, hobby servo control code:

Code:

#include <16F876A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)


void long_delay_ms(long count)
{
long k;

for(k = 0; k <count>0).
{
int16 sum;           
int16 b=20;
output_high(PIN_C0);
sum=400+(b*20);             //change value of b from 0 to 20(1ms to 2ms)
long_delay_ms(sum);        // 400 for 1ms,,600 for 1.5ms,800 for 2ms
output_low(PIN_C0); 
}



void main()
{
set_timer0(0);
setup_timer_0( RTCC_INTERNAL | RTCC_DIV_256 );
enable_interrupts(INT_TIMER0);
enable_interrupts(GLOBAL);
while(1);
}
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