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

changing frequencies

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



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

changing frequencies
PostPosted: Fri Aug 03, 2012 8:21 pm     Reply with quote

hi,

First time trying this frequency changing deal...
from reading some of the posts here i concluded that:

at the beginning of my main:
Code:
while(!((SETUP_OSCILLATOR(OSC_NORMAL))& OSC_STATE_STABLE)); // Waits till oscillator is stable   


Later in Main:
Code:
while(!((SETUP_OSCILLATOR(OSC_4MHZ))& OSC_STATE_STABLE)); // Waits till oscillator is stable   



am i actually waiting for it to stabilize? or am i missing something..
seems to be working though...

going from 20M to 4M

16F886.

thanks!
_________________
CCS PCM 5.078 & CCS PCH 5.093
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Fri Aug 03, 2012 9:02 pm     Reply with quote

I have not done that, but don't forget if you change the osc. freq, you will also change any delay statements and any baud rates you are using.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Sat Aug 04, 2012 6:14 am     Reply with quote

yeap... im _very_ aware of changing the delay statement and baud rates...
im asking this question precisely because im having issues doing just that and i just want to clearout the small things...

i really dont have a clear idea on how to use the OSC_STATE_STABLE value or variable... i dont know what the hell it is ....

the .h file seems (from PCM's Comments on other posts) to mention that its not a return value but a mask to isolate the Setup_oscillator _actual_return value bits.... very confusing.

thanks..
G
_________________
CCS PCM 5.078 & CCS PCH 5.093
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Aug 04, 2012 7:49 am     Reply with quote

In section 4.2 (oscillator control) of the datasheet it has this for the 31KHZ and HS oscillators:

Quote:
bit 2 HTS: HFINTOSC Status bit (High Frequency – 8 MHz to 125 kHz)
1 = HFINTOSC is stable
0 = HFINTOSC is not stable

bit 1 LTS: LFINTOSC Stable bit (Low Frequency – 31 kHz)
1 = LFINTOSC is stable
0 = LFINTOSC is not stable


In the PIC16F886.h header file it has this:
Quote:
#define OSC_STATE_STABLE 4
#define OSC_31KHZ_STABLE 2


So, the bit is used to determine when the oscillator has stabilized after a
startup or frequency switch.

You don't have to worry about it or do anything. When the
"setup_oscillator" statement is executed it will test the HFINTOSC bit and
wait until the oscillator is stable before continuing.
_________________
Google and Forum Search are some of your best tools!!!!
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sat Aug 04, 2012 11:24 am     Reply with quote

Definitely read the section of the datasheet for your PIC a few times (soak it in) about the Oscillator... I did a few times and then experimented to make sure it was doing what I wanted.

I did an 18F46J11 project that switched between 10 and 40 MHz -- worked swell.

Had to deal with change in delays and baud rates -- but all was good once all those factors were accounted for.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
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