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 CCS Technical Support

Internal Clock setup for 18F67J11

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



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

View user's profile Send private message

Internal Clock setup for 18F67J11
PostPosted: Fri Mar 06, 2009 11:49 am     Reply with quote

I have code written for an 18F67J10 with external oscillator. I tried porting this to an 18F67J11 using the internal oscillator and PLL but for the life of me I can't get the oscillator to change away from 4MHz.

I am using 4.087 and this is on a custom pcb, not simulation.
Both the debugger and the beta ccsload program with ICD show 4MHz.

I have tried the setup_oscillator inside main using:
Code:
   setup_oscillator(OSC_32MHZ | OSC_PLL_ON);


and inside the .h file:
Code:
#FUSES H4_SW

#use delay(clock=32000000)


The OSCON register and OSCTUNE register never appear to change from their default values no matter how I change the above code.

Any help would be appreciated.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 06, 2009 12:08 pm     Reply with quote

Quote:
and inside the .h file:
Code:
#FUSES H4_SW

Look at the two fuses at the end of the fuse list in the 18F67J11.h file.
bwhiten



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

View user's profile Send private message

PostPosted: Fri Mar 06, 2009 12:20 pm     Reply with quote

I had tried those two fuse options as well:

INTRC_PLL and INTRC_PLL_IO

The OSCTUNE register bit for PLLEN never changes and the clock source bits in OSCCON stick at PRIMARY instead of INTERNAL.

Still running at 4MHz unfortunately.

It seems the FOSC bits in the configuration register are not changing the primary clock source to internal.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 06, 2009 12:46 pm     Reply with quote

How are you determining that it's running at 4 MHz ? What method are
you using to find the frequency ?

I don't have this PIC, but I think this will work:
Code:

#include <18F67J11.h>
#fuses INTRC_PLL_IO,NOWDT,NOPROTECT
#use delay(clock=32000000)

//================================
void main()
{

setup_oscillator(OSC_PLL_ON | OSC_32MHZ );

while(1);
}
bwhiten



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

View user's profile Send private message

PostPosted: Fri Mar 06, 2009 1:01 pm     Reply with quote

The Debugger in PCW, CCS IDE, displays the clock frequency.
And the new beta version of CCSLOAD reports the clock frequency of the device.

They both show 4MHz. In addition I'm looking at the special function registers using the CCS debugger.

I tried your test program and still measure 4MHz.
I think I need to look closer at the assembly output to see why the PLLEN bit is not being set.

Thanks for the help.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 06, 2009 1:47 pm     Reply with quote

The PLLEN bit is being set. See the lines in bold below.
I think you should put an oscilloscope on the OSC2/CLKO/RA6 pin and
measure the frequency on that pin. It should be Fosc/4. So it you're
running at 32 MHz, then you should see 8 MHz on that pin.
Quote:

.... void main()
.... {
00004: CLRF TBLPTRU
00006: BCF RCON.IPEN
00008: CLRF FSR0H
0000A: CLRF FSR0L
0000C: BSF WDTCON.ADSHR
0000E: MOVLW FF
00010: MOVWF ADCON1
00012: BCF WDTCON.ADSHR
00014: BCF ADCON0.VCFG0
00016: BCF ADCON0.VCFG1
00018: BSF WDTCON.ADSHR
0001A: MOVWF ADCON0
0001C: BCF WDTCON.ADSHR
0001E: CLRF CM1CON1
00020: CLRF CM2CON1
....
.... setup_oscillator(OSC_PLL_ON | OSC_32MHZ );
00022: MOVLW 70
00024: MOVWF OSCCON
00026: MOVLW 40
00028: MOVWF OSCTUNE
0002A: MOVF OSCCON,W
.... while(1);
0002C: BRA 002C
.... }
bwhiten



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

View user's profile Send private message

PostPosted: Sun Mar 08, 2009 1:04 pm     Reply with quote

OK. Used INTRC_PLL and measured the output on CLKO on the scope without the CCS ICD connected. As you stated, 8MHz, so internal at 32MHz as I wanted. Then I connected the ICD and ran the CCS debugger window and sure enough the output at CLKO dropped to 1MHz, so 4MHz internal as measured by the ICD. I'm not sure what to think about that. I'm positive that with an external crystal I've seen the debugger measure the PIC frequency at 20MHz and higher. Is there a limitation when using the ICD?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 08, 2009 4:31 pm     Reply with quote

It could be a bug in the ICD firmware, as described in this thread about
an similar ICD2 problem:
http://www.ccsinfo.com/forum/viewtopic.php?t=36592
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