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 support@ccsinfo.com

need code for internal oscilator for 16f88

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







need code for internal oscilator for 16f88
PostPosted: Tue Feb 17, 2004 1:20 am     Reply with quote

Hello everyone.
I need a simple code to set up for 4Mhz internal oscilator for 16f88 mcu
Al



Joined: 13 Nov 2003
Posts: 28
Location: Belfast

View user's profile Send private message

Re: need code for internal oscilator for 16f88
PostPosted: Tue Feb 17, 2004 3:06 am     Reply with quote

tomtln wrote:
Hello everyone.
I need a simple code to set up for 4Mhz internal oscilator for 16f88 mcu


I guess it is no the same as it would be for any other PIC, eg:

#include <16F88.h>
#use delay(clock=4000000)
_________________
Alan Murray
neil



Joined: 08 Sep 2003
Posts: 128

View user's profile Send private message

try this....
PostPosted: Tue Feb 17, 2004 5:20 am     Reply with quote

Hi Tom, try including the fuse: INTRC_IO, or INTRC if you want clkout on pin 15. As for selecting the speed, I don't think the #use delay will do this, as it is only there to tell the compiler how to generate its delay functions. See quote from manual:
Quote:
Tells the compiler the speed of the processor and enables the use of the built-in functions: delay_ms() and delay_us(). Speed is in cycles per second. An optional restart_WDT may be used to cause the compiler to restart the WDT while delaying.

If you are not using the internal delay functions (I try not to!) I don't think you will need this line! I can't find a command to configure the clock speed, I would expect it to be in the fuses line, but it is not. Try using assembler to setup the clock speed. See pages 38-41 on datasheet. Try the #use delay... line and see if it configures the speed, looking at the frequency on the clkout pin. (Use INTRC as the fuse). If this fails, try putting this code right at the start of your code:
Code:
#asm
    movlw 0x6A;   // put clock config word in W reg.
    iorwf 0x8F;      // OR config word with 'OSCCON' register (8Fh).
#endasm

There must be an easier way though? Anyone?!

Neil.
bwhiten



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

PostPosted: Tue Feb 17, 2004 9:05 am     Reply with quote

You need to declare the Oscillator Control Register address, so in my include file I have these two lines:

#byte OSCCON = 0x8F
#use delay(clock=4000000)

Then to set the frequency to 4MHz, according to the data sheet, in my main() I have the following line:

OSCCON = 0x6C;
Guest








PostPosted: Thu Aug 19, 2004 5:34 pm     Reply with quote

newest version of ccs compiler has a built in function for this

Code:

#FUSES INTRC,...
#use delay(clock=8000000)

void main(){
    setup_oscillator(OSC_8MHZ | OSC_INTRC);
}


the different options are listed in the header
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