View previous topic :: View next topic |
Author |
Message |
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
delay_ms vs. osc speed. |
Posted: Fri May 20, 2016 7:06 am |
|
|
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
|
|
Posted: Fri May 20, 2016 7:37 am |
|
|
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
|
|
Posted: Fri May 20, 2016 8:09 am |
|
|
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
|
|
Posted: Fri May 20, 2016 11:25 am |
|
|
@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
|
|
Posted: Sat May 21, 2016 2:53 am |
|
|
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. |
|
|
|