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

testing osscon for stable

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







testing osscon for stable
PostPosted: Mon May 12, 2008 6:59 pm     Reply with quote

I am just starting to convert a SourceBoost C program to CCS and so have a few questions that are probably elementary to most of you.

My first question has to do with the first lines of code in my SourceBoost program starts:

osccon = 0b01110000; //Setup internal oscillator for 8MHz
while(osccon.2 == 0) ; //Wait for frequency to stabilize

I used the project wizard to create my first project and it generated this line in main:

setup_oscillator(OSC_8MHZ|OSC_INTRC);

but it doesn't wait for the frequency to stabilize. In Help it says that setup_oscillator sometimes returns a value that can be tested for stability and I see that in the PIC16F88 header file there is something called OSSCON_STATE_STABLE. So, on a lark I gave this a try:

while(setup_oscillator(OSC_8MHZ|OSC_INTRC) != OSC_STATE_STABLE);

It compiles with a warning that operator precedence might not be as intended, which I don't really understand.

I also tried this:

while(OSSCON.2 == 0) ;

but got another warning, this time telling me that OSSCON is always false. So, I guess there is a different way of addressing bit 2 of the OSSCON register, right?

So, what is this the right way of doing this very common operation?
n-squared



Joined: 03 Oct 2006
Posts: 99

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon May 12, 2008 9:17 pm     Reply with quote

Hi,

Try the following:

Code:

#byte     OSCCON    = 0xFD3
#bit        STABLE      = OSCCON.2


 setup_oscillator(OSC_8MHZ|OSC_INTRC);
 while (!STABLE);



Good luck
Noam
_________________
Every solution has a problem.
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