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

PIC18F87J60 with HSPLL don't work

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



Joined: 09 Dec 2010
Posts: 3

View user's profile Send private message

PIC18F87J60 with HSPLL don't work
PostPosted: Thu Dec 09, 2010 5:18 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 6:19 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 6:52 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 9:43 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 9:51 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 10:09 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 10:26 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 10:35 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 10:42 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 10:57 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 11:01 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 11:05 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 4:05 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 4:30 pm     Reply with quote

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
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