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_ms vs. osc speed.

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



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

delay_ms vs. osc speed.
PostPosted: Fri May 20, 2016 7:06 am     Reply with quote

I have a program that uses three different oscillator configurations, I declared 48MHz at top of the program which is the usual speed but when is in low power mode I need to perform delays and the compiler make the calculation for 48MHz.
So, There's any way to indicate to the compiler that the main OSC is in a lower speed and the delay must use less cycles?
_________________
Electric Blue
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Fri May 20, 2016 7:37 am     Reply with quote

post your code. TIMERS are your friend.
use a TIMER driven by Fosc for delays and then set a flag variable to indicate what Fosc value is active.
Then make your timer delays adjustable.

I could code this pretty quickly - but you have not
shown your pic or program structure..
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 20, 2016 8:09 am     Reply with quote

You asked this same question back in 2012. This post and the links in it
provide some answers.
http://www.ccsinfo.com/forum/viewtopic.php?t=47729
I suppose you're asking if there are any new features to the compiler
that allow this to be done more easily.
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Fri May 20, 2016 11:25 am     Reply with quote

@asmboy
Thanks, I think I will keep using TMR1 which is connected to a 32.768Khz crystal.

@PCM programmer
Yes, I'm trying to improve the code and making some changes.
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Sat May 21, 2016 2:53 am     Reply with quote

I think the route outlined in the code PCM_programmer pointed to, of using a stored 'multiplier factor' with the settings being done for the lower clock rate is by far the easiest and tidiest. A macro, or function can then be used for all timer calls.
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