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

Setting clock on 18F67J60

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



Joined: 09 Feb 2007
Posts: 55

View user's profile Send private message

Setting clock on 18F67J60
PostPosted: Thu Jan 17, 2008 8:32 am     Reply with quote

Hello,

Can anyone suggest how the following clock conditions on the 18F67J60 chip can be set?

PLL Prescaler = /3
PLL5 = enabled
PLL Postscaler = disabled

My board has a 25MHz crystal and I am trying to set the internal clock frequency to 41.6667MHz.

I have tried the following:

#byte osctune=0xFD3
osctune = 0x40;

But it has not helped. The internal clock remains at 25MHz.

Thanks!
CCS_HELPER
Guest







PostPosted: Thu Jan 17, 2008 9:42 am     Reply with quote

I'm working from memory, but this should point you in the right direction:

1) Make sure you have the HSPLL or H4_SW fuse set (can't remember which it is)

2) Search the 18F67J60 header file for "setup_oscillator". There should be an option such as PLL_5_DIV_3 or something like that. Call the function setup_oscillator(PLL_5_DIV_3); (or whatever constant you find in the header file) from main().

Do both of these and you should be good to go!
nazoa



Joined: 09 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Thu Jan 17, 2008 11:05 am     Reply with quote

Thanks for the suggestions but I have tried them all. HSPLL does not exist and H4_SW does help. PLL5_5_DIV_3 or PLL5 or anything else is not on the header file and what I have tried generates a compilation error.

Any other suggestions?
nazoa



Joined: 09 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Thu Jan 17, 2008 11:48 am     Reply with quote

I have tried adding setup_oscillator(OSC_PLL_5_DIV_3); in the main code and the compiler listing shows the following:

0AAFE: MOVLW 40
0AB00: MOVWF F9B
0AB02: CLRF FD3
0AB04: MOVF FD3,W

I am not sure but I think this writing 0x40 to address F9B which is the OSCTUNE register which is what is needed. But it still does not help.

I tried writing directly to the OSCTUNE register but that does not help either!

Question
CCS_HELPER
Guest







PostPosted: Thu Jan 17, 2008 12:35 pm     Reply with quote

what compiler version are you using? I haven't checked the ASM listing you posted to see if it's correct, but earlier version 4 compilers generated incorrect code for the setup_oscillator() function on this chip.
nazoa



Joined: 09 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Thu Jan 17, 2008 4:25 pm     Reply with quote

OK, I am using 4.065 and have run out of ideas..

Probably not relevant, but I am using the CCS ethernet kit board with the web server example.

Thanks.



Question
RossJ



Joined: 25 Aug 2004
Posts: 66

View user's profile Send private message

PostPosted: Thu Jan 17, 2008 5:47 pm     Reply with quote

There are essentially 3 things you need to set to control the oscillator: OSCCON, OSCTUNE and the FOSC2:0 fuses. If you want to eliminate the compiler as a possible source of your problem, start by writing the registers directly (as you have done above).

With the code you indicated above:

0AAFE: MOVLW 40
0AB00: MOVWF F9B
0AB02: CLRF FD3
0AB04: MOVF FD3,W

Your OSCTUNE settings will produce the desired frequency so long as the fuses are set to one of the two PLL modes, otherwise the PLL, prescaler and postscaler are all disabled (i.e. what you are getting).

Your OSCCON settings are such that the fuses MUST be set correctly.

The fuses FOSC2:0 are set with the compiler symbols PRIMARY and H4_SW. Make sure you don't have any other oscillator related fuses set (i.e. HS,EC_IO,E4_SW_IO,INTRC). If you have any doubts as to what the different fuse names are (H4_SW is a very odd name given that this is not a x4 PLL), the device editor has all the definitions. Also, take a look at the bottom of the .LST file where you can see the actual hex values of the fuses. Make sure the oscillator values are as you expect.
nazoa



Joined: 09 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Fri Jan 18, 2008 3:13 am     Reply with quote

Thank you RossJ this has fixed the problem. It was the oddly named H4_SW that I had not tried.

Thanks again.
Very Happy
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