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

PIC18 Strange Clock Frequency.

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



Joined: 14 Aug 2012
Posts: 16

View user's profile Send private message

PIC18 Strange Clock Frequency.
PostPosted: Sun Sep 30, 2012 8:14 am     Reply with quote

Hi.

I have a PIC18F87K90 mounted on a experimental board.
I'm using a 64MHz oscillator for the clock.
The oscilloscope says that the actual frequency is 64MHz, OK.
When I run my software with the debugger via ICD64, it reports 120,47MHz instead.
Is there something wrong?

Code:

#include <18F87K90.h>
#device ICD=TRUE
#device adc=10
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES ECH_IO                   //External clock ,high power
#FUSES PUT                      //Power Up Timer
#FUSES NOBROWNOUT               //No brownout reset
#FUSES WDT_NOSLEEP              //Watch Dog Timer, disabled during SLEEP
#use delay(clock=64000000)




Compiler v. 4.124
Thank you!
Rob_975



Joined: 14 Aug 2012
Posts: 16

View user's profile Send private message

PostPosted: Sun Sep 30, 2012 8:57 am     Reply with quote

I did some further investigations.
I have a LED on the board.
with the
Code:
#use delay(clock=64000000)

the on/off timing of the led is half the time I set in the software.

If I set
Code:
#use delay(clock=120000000)


the LED is blinking correctly.
It seems to me that something is telling the PIC to go 120MHz instead of 64MHz altough the oscillator is providing a 64MHz clock.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sun Sep 30, 2012 3:18 pm     Reply with quote

Have you tried using a 16mhz oscillator in ec2 mode with the 4x PLL ??
Rob_975



Joined: 14 Aug 2012
Posts: 16

View user's profile Send private message

PostPosted: Mon Oct 01, 2012 2:04 am     Reply with quote

asmboy wrote:
Have you tried using a 16mhz oscillator in ec2 mode with the 4x PLL ??


It'll be difficult as the oscillator is a small SMD package and I don't have the 16MHz one.
Crazy.
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Mon Oct 01, 2012 2:30 am     Reply with quote

Have you actually tried what happens if you turn off debugging, and run it in the chip for real instead?.
I have a nasty suspicion there may be a problem with the ICD, rather than the code.
Add NOPLLEN to the fuses (just worth trying), and literally do a one second on, one second off LED flash, using no other hardware, program this into the chip and see if this works. If it does then the compiler is getting it right.

Best Wishes
Rob_975



Joined: 14 Aug 2012
Posts: 16

View user's profile Send private message

PostPosted: Mon Oct 01, 2012 12:06 pm     Reply with quote

Ttelmah wrote:
...Add NOPLLEN to the fuses (just worth trying), and literally do a one second on, one second off LED flash, using no other hardware, program this into the chip and see if this works. If it does then the compiler is getting it right.

Best Wishes


Solved!
The NOPLLEN fuse did it.
I thought that a PIC configured with the external oscillator (via fuse), should have the PLL disabled by default.
Now the degugger is giving 64.00MHz and the on/off time of the led is correct.

Thank you all!
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