Page 1 of 1

Use of internal oscillator

Posted: Mon Jan 16, 2006 6:13 pm
by Steve
We've just answered a technical support question which I thought may interest other FlowCode users, so here's the question, followed by an answer:
How do I use the internal oscillator of the 16F88 chip within FlowCode?
The chip in question needs to be configured to use the internal oscillator block, so in the configuration screen (PIC...Configure...) select one of the INTRC options for the oscillator selection drop-down.

Next, at the beginning of the main flowchart in your program, add a 'C' icon and write the following line into it:

Code: Select all

osccon = 0x70;
This will set the internal oscillator block to run at 8MHz. Other speeds can also be set, e.g. for 4MHz, use 0x60. See the 16F88 datasheet for more info.

That should be it. Remember to set the appropriate clock speed in the PIC...Clock Speed window, otherwise your program's delays may be calculated incorrectly and your 100ms pause may take a few minutes!

more questions.......

Posted: Tue Jan 17, 2006 3:38 am
by Edshere
Steve thanks for the quick reply. That is truely great service.

But since I am brand new to this pic chip stuff, I have other questions. Regarding the datasheet and the oscon register 4.2 on pdf page 42. I know why you set bit 3 to zero, bu why bit 2 and 0-1?

Bit 2 is the stable bit. By setting this to 0 (not stable) are we saying that this freq may jump around and telling the chip to expect variations?

Bit 1-0 is the osc mode. You have this set to 00 (Oscillator mode defined by FOSC<2:0>), why not 10 (Internal RC is used for system clock)??

Like I said, I am brand new to this and if I ask stupid questions, I apologize. I appreciate any/all information you give.

Posted: Tue Jan 17, 2006 10:41 am
by Steve
Hi Edshere (Ed?),

That's not a stupid question - the clock modes for the '88 chip are extensive and confusing. But take my reply here with a pinch of salt because I'm not 100% sure...

It looks like bit 2 (IOFS) indicates that the clock frequency is stable and is actually read-only - although the datasheet says it's R/W in the OSCCON table, I think that this is a typo because all references to this bit infer that it is read-only.

Bit's 0:1 (SCS) do look like they perform the same function as the oscillator seletion bits of the configuration word, but they allow clock switching on the fly (i.e. when your program is actually running). This feature is typically used when the application is power-sensitive and there is a temporary requirement to keep the processor running while using as little power as possible. By switching to the 32KHz internal clock, the application can still run (slowly) with greatly reduced power consumption.

I guess that to use this feature, you must enable clock switching in the configuration word.

Microchip's website (and forums) may well provide a more complete and accurate source of info, or there may be others on this forum that could provide a better answer...

Thanks

Posted: Tue Jan 17, 2006 1:49 pm
by Edshere
Thanks for the help Steve. I appreciate it.

Now I'm off to the next issue, not sure what it is yet, but i'm sure it will come up soon enough.

Ed.