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

First use of 18F4620 - Internal oscillator and adc

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



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

View user's profile Send private message

PostPosted: Fri Jan 14, 2011 8:50 am     Reply with quote

I am using the ICD-U64 with an 18F46K22 and it reports I am running at 1MHZ even though I have verified I am running at 64MHZ using a scope.

As Ttelmah said earlier, try using setup_oscillator(). From the header:

Code:

////////////////////////////////////////////////////////////////// INTERNAL RC
// Constants used in setup_oscillator() are:
// First param:
#define OSC_31KHZ   0
#define OSC_125KHZ  0x10
#define OSC_250KHZ  0x20
#define OSC_500KHZ  0x30
#define OSC_1MHZ    0x40
#define OSC_2MHZ    0x50
#define OSC_4MHZ    0x60
#define OSC_8MHZ    0x70
#define OSC_16MHZ   0x4060
#define OSC_32MHZ   0x4070
// The following may be OR'ed in with the above using |
#define OSC_TIMER1  1
#define OSC_INTRC   2
#define OSC_NORMAL  0
// The following may be OR'ed in with the above using |
#define OSC_IDLE_MODE  0x80
#define OSC_31250   0x8000
#define OSC_PLL_ON  0x4000
#define OSC_PLL_OFF 0
// A second optional parameter may be used with this part to fine
// tune the speed (signed int,0-31)
// Result may be (ignore all other bits)
#define OSC_STATE_STABLE 4
#define OSC_STATE_EXT_RUNNING 8

_________________
Google and Forum Search are some of your best tools!!!!
tonymcc



Joined: 27 Jul 2010
Posts: 15
Location: Northampton UK Home of the 'Big Sheds'

View user's profile Send private message

Thanks dyeatman
PostPosted: Fri Jan 14, 2011 9:25 am     Reply with quote

I must be going blind to have missed this section in the processor header and not associate with OSCCON in the data sheet. I have tried now using setup_oscillator(OSC_INTRC | OSC_8MHZ);
but still get my 2MHz at pin 14. Well, it is Friday, thanks very much for your advice.
dyeatman



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

View user's profile Send private message

PostPosted: Fri Jan 14, 2011 9:35 am     Reply with quote

From the datasheet:
Quote:

2.6.1 INTIO MODES
Using the internal oscillator as the clock source
eliminates the need for up to two external oscillator
pins, which can then be used for digital I/O. Two distinct
configurations are available:
In INTIO1 mode, the OSC2 pin outputs FOSC/4,
while OSC1 functions as RA7 for digital input and
output.

• In INTIO2 mode, OSC1 functions as RA7 and
OSC2 functions as RA6, both for digital input and
output.


So 8MHZ/4=2MHZ is correct on pin 14.
_________________
Google and Forum Search are some of your best tools!!!!
tonymcc



Joined: 27 Jul 2010
Posts: 15
Location: Northampton UK Home of the 'Big Sheds'

View user's profile Send private message

PostPosted: Fri Jan 14, 2011 9:41 am     Reply with quote

Thanks again. You are, of course, correct. So, my original #fuse INTRC plus the #use_delay(clock=8000000) directive did work, I just misinterpreted the results. I checked with a few other frequencies and all is well. A learning day.
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