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_ms calculation

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



Joined: 06 Jul 2009
Posts: 4

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

Delay_ms calculation
PostPosted: Mon Sep 28, 2009 8:33 am     Reply with quote

I am trying to create a variable clock pulse out of an IO on a port for an L297 stepper driver. I use an ADC to measure the input voltage between 1 and 5 VDC. That value is converted to a time value between 1 and 100 ms which is placed in the delay_ms() function. I noticed howver that the actual delay is much longer than it should be . Does the delay_ms function have anything to do with the oscillator frequency?

I am using a PIC 16F877A with a 4 MHz crystal. I'm simulating all of this using Proteus to do some initial development.
Ttelmah
Guest







PostPosted: Mon Sep 28, 2009 9:03 am     Reply with quote

Of course it is dependant on clock frequency. The 'clock', is the only time 'source' in the chip...

To get 'correct' delays, two things have to apply:

1) The timing set in the 'clock' statement, must match the actual oscillator you are using.
2) If using a simulator, the timings set in this, must also match the oscillator.

Best Wishes
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