View previous topic :: View next topic |
Author |
Message |
Rob_975
Joined: 14 Aug 2012 Posts: 16
|
PIC18 Strange Clock Frequency. |
Posted: Sun Sep 30, 2012 8:14 am |
|
|
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
|
|
Posted: Sun Sep 30, 2012 8:57 am |
|
|
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
|
|
Posted: Sun Sep 30, 2012 3:18 pm |
|
|
Have you tried using a 16mhz oscillator in ec2 mode with the 4x PLL ?? |
|
|
Rob_975
Joined: 14 Aug 2012 Posts: 16
|
|
Posted: Mon Oct 01, 2012 2:04 am |
|
|
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: 19497
|
|
Posted: Mon Oct 01, 2012 2:30 am |
|
|
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
|
|
Posted: Mon Oct 01, 2012 12:06 pm |
|
|
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! |
|
|
|