View previous topic :: View next topic |
Author |
Message |
hevemarc
Joined: 09 Dec 2010 Posts: 3
|
PIC18F87J60 with HSPLL don't work |
Posted: Thu Dec 09, 2010 5:18 am |
|
|
I am using a 25Mhz crystal in my project, but this doesn't work when I use #fuse HSPLL. The microcontroller is slow, almost stopping... is there something more for me to configure?
This is my code:
Code: |
#include <18F87J60.h>
#use delay(clock=41666667) //xtal 25MHZ
#FUSES HSPLL
#FUSES NOWDT
void main(void)
{
while(true)
{
output_high(pin_e0);
delay_ms(1000);
output_low(pin_e0);
delay_ms(1000);
}
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Thu Dec 09, 2010 6:19 am |
|
|
Think about it for a moment. The PLL, requires configuration of the prescaler, and postscaler. The compiler can do this for you, but _only_ if you give it the information it needs. Nowhere are you telling it that your crystal is 25MHz, so how is it meant tot configure these settings?. Guesswork?.
Best Wishes |
|
|
hevemarc
Joined: 09 Dec 2010 Posts: 3
|
|
Posted: Thu Dec 09, 2010 6:52 am |
|
|
I already tried to use the directive #use delay(oscillator=25Mhz, clock=41666667Mhz), but continued of the same mode...
I don't know how I give the information of prescaler and postscaler for the compiler...
I also already tried to use the directive #use dalay(clock=25MHZ) and to use #fuse HS for work as default, but not worked.
it should be lacking some information yes...
I don't only know which...
best regards |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Thu Dec 09, 2010 9:43 am |
|
|
OK. Now you have told us you are giving the compiler some information, obvious question 'what compiler version'?.
Best Wishes |
|
|
hevemarc
Joined: 09 Dec 2010 Posts: 3
|
|
Posted: Thu Dec 09, 2010 9:51 am |
|
|
I'm using a CCS compiler version 4.110
Now I am trying to use those commands to change the registers:
Code: |
#byte OSCCON = 0x02
#byte OSCTUNE = 0x40
|
I think that the problem is with the configuration of the oscillator because the pic run very slowly.
best regards |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Thu Dec 09, 2010 10:09 am |
|
|
Puzzled now, since HSPLL, is _not_ a valid fuse for the 18J90, with 4.110. Since you were using this, I was assuming you had a very old compiler.
What you posted should not even compile with 4.110
A quick test, loading your posted code, removing HSPLL, and setting crystal=25000000, compiling, and transferring to MPLAB, shows the PLL being correctly set in this version, but the fuses selecting 'EC', not HS by default, so the oscillator won't be starting at all, and the chip will be falling 'back' to the failsafe oscillator.
Selecting:
Code: |
#include <18F87J60.h>
#use delay(clock=41666667, crystal=25000000) //xtal 25MHZ
#FUSES NOWDT,NOXINST,H4_SW
|
Appears to give the required configuration.
Best Wishes |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Thu Dec 09, 2010 10:26 am |
|
|
I am using the 97J60 and the following produces the required result:-
Code: |
#use delay(oscillator=25Mhz, clock=41.6667Mhz)
|
Not quite so many 6s
Also using HS or H4_SW makes no difference! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Thu Dec 09, 2010 10:35 am |
|
|
Interesting. With 4.110?.
The point is that simply setting the crystal and clock (which does work for many other chips), seems to select the wrong oscillator on the 87J60/4.110. As I said, I found that this gave EC+PLL, which requires an external oscillator, not a crystal. Changing to H4_SW, selected the HS+PLL option as required.
Best Wishes |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Thu Dec 09, 2010 10:42 am |
|
|
Changing the fuse HS or H4_SW does alter the fuses settings in the .lst file but does not change the frequency at which it is running.
Using crystal= or osc= makes no difference to the fuse settings.
#use delay(crystal=25Mhz, clock=41.6667Mhz) Pic runs at 41.6667MHz
#use delay(clock=25Mhz) Pic runs at 25MHz
On actual hardware.
Compiler = 4.114 |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Thu Dec 09, 2010 10:57 am |
|
|
I've been playing with my 97J60 for something else recently...
on PCH 4.114 (my version)
I've been doing:
#fuses H4_SW // remember, the j60 is a software enabled PLL.
#use delay (clock=41.667M, crystal=25M)
and then in main()
setup_oscillator(OSC_PLL_5_DIV_3);
Let me know if that helps.
Cheers,
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Thu Dec 09, 2010 11:01 am |
|
|
Big difference, 4.114, not 4.110.
As I said, loading the file into MPLAB, shows that on 4.110, the compiler the poster is using, if you don't select H4_SW, the oscillator is set to EC, which won't run without an external oscillator. Also, behoves the question, do you have a crystal, or an oscillator module?. This wouldn't care....
Best Wishes |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Thu Dec 09, 2010 11:05 am |
|
|
Ttelmah wrote: | Big difference, 4.114, not 4.110.
|
I know, that's why I said I was using 4.114.
At least there's *some* frame of reference. Yay.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Thu Dec 09, 2010 4:05 pm |
|
|
I was replying to Wayne, not you. The old 'takes time to post' syndrome.....
Best Wishes |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Thu Dec 09, 2010 4:30 pm |
|
|
Ttelmah wrote: | I was replying to Wayne, not you. The old 'takes time to post' syndrome.....
|
Indeed!
Happy Holidays,
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
|