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:
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
Posted: Mon May 12, 2008 9:17 pm
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.
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