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

#FUSE HSPLL problem

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



Joined: 05 Apr 2011
Posts: 12

View user's profile Send private message

#FUSE HSPLL problem
PostPosted: Wed Sep 14, 2011 3:40 am     Reply with quote

Hi,

I am using compiler version 4.100 and PIC18F4680 and can't set the fuse for HSPLL within the code. I get the following error:

Line 58(7,13): Unknown keyword in #FUSES "HSPLL"

However, I can set it ok when I manually set the configuration bits every time I compile, which is a pain.

I assume it is a compiler bug, but am reluctant to upgrade my compiler. Does anyone know a work-around?

I tried using #FUSES 1=0x0C00 and this compiles but the PLL is off.

Many thanks

magic_mauve
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Wed Sep 14, 2011 9:40 am     Reply with quote

On this compiler version, for this chip, the fuse is 'H4', not HSPLL.
The fuses in this area are at times really designed to confuse, with CCS not being reliable in their naming - always start by reading the first few lines on the include file for the chip, where legal fuses are listed, and then see if you can work out the one you want!....

Best Wishes
magic_mauve



Joined: 05 Apr 2011
Posts: 12

View user's profile Send private message

PostPosted: Wed Sep 14, 2011 10:05 am     Reply with quote

Thanks for your speedy response. I have tried H4, which compiles ok, but has no effect on the speed of my program. When I set HS+PLL in the config bits everything speeds up.

Is there something else I should be doing?

magic_mauve
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Wed Sep 14, 2011 2:42 pm     Reply with quote

The simple way to find out what is actually programmed is to look at the last few lines of the hex file. It may well be that your compiler version does not correctly set the PLL on this chip.

Best Wishes
asmboy



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

View user's profile Send private message AIM Address

PostPosted: Wed Sep 14, 2011 3:08 pm     Reply with quote

the Micro engineering Labs USB PIC programmer has a
very nice fuse option window that lets you see and manipulate
the fuses in your HEX file

i've used it several times to verify , then alter, and resave --
only the fuses in an already compiled file, with "great joy".
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Sep 14, 2011 3:28 pm     Reply with quote

Try this test program. Install a 10 MHz crystal (and capacitors) on the
PIC and see if the LED blinks once per second (1 Hz).
Code:

#include <18F4680.h>
#fuses H4,NOWDT,PUT,BROWNOUT,NOPBADEN,NOLVP
#use delay(clock=40M)

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

while(1)
  {
   output_toggle(PIN_B0);  // Blink LED
   delay_ms(500);
  }

}
magic_mauve



Joined: 05 Apr 2011
Posts: 12

View user's profile Send private message

PostPosted: Thu Sep 15, 2011 2:32 am     Reply with quote

Thanks for all this advice. I have made progress as I can spot the byte I need to change in the hex file to set up the PLL correctly. Does anyone know how the checksum is calculated for a line in the hex file? This needs changing too before I can program.

Thanks

magic_mauve
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Thu Sep 15, 2011 4:10 am     Reply with quote

The checksum is 'standard' Intel Hex. Any number of websites giving details of this.
However you can just set the byte using a #ROM statement, and the checksum is then calculated for you.
Do you have the IDE?. If so, you can set the fuses from the device editor.

However getting more puzzled what is going on.....

Just took PCM programmer's demo program. Compiled it 'as is', with 4.100, loaded it into my programmer, and it correctly has the PLL setup.
The compiler _is_ setting the bits correctly.

Loading it into MPLAB, gives:
Code:

300001   06  OSC   Oscillator             HS-PLL enabled freq=4xFosc1


Then, just to be sure, went back in time to V4.070, and this too sets the PLL correctly. Then tried 4.104, and so does this.
Code:

//From 4.070
Configuration Fuses:
   Word  1: 0600   H4 NOIESO NOFCMEN RESERVED
   Word  2: 1E1E   BROWNOUT NOWDT BORV21 PUT WDT32768
   Word  3: 8000   NOPBADEN NOLPT1OSC MCLR RESERVED
   Word  4: 0081   STVREN NODEBUG NOLVP BBSIZ1K NOXINST RESERVED
   Word  5: C00F   NOPROTECT NOCPD NOCPB
   Word  6: E00F   NOWRT NOWRTD NOWRTC NOWRTB
   Word  7: 400F   NOEBTR NOEBTRB
//From 4.100
Configuration Fuses:
   Word  1: 0600   H4 NOIESO NOFCMEN
   Word  2: 1E1E   BROWNOUT NOWDT BORV21 PUT WDT32768
   Word  3: 8000   NOPBADEN NOLPT1OSC MCLR
   Word  4: 0081   STVREN NODEBUG NOLVP BBSIZ1K NOXINST
   Word  5: C00F   NOPROTECT NOCPD NOCPB
   Word  6: E00F   NOWRT NOWRTD NOWRTC NOWRTB
   Word  7: 400F   NOEBTR NOEBTRB
//From 4.104
Configuration Fuses:
   Word  1: C600   H4 IESO FCMEN
   Word  2: 1E1E   BROWNOUT NOWDT BORV21 PUT WDT32768
   Word  3: 8400   NOPBADEN LPT1OSC MCLR
   Word  4: 00B1   STVREN NODEBUG NOLVP NOXINST BBSIZ4K
   Word  5: C00F   NOPROTECT NOCPD NOCPB
   Word  6: E00F   NOWRT NOWRTD NOWRTC NOWRTB
   Word  7: 400F   NOEBTR NOEBTRB

All are correctly setting the PLL.

Then tried another test. Manually set the byte using the #fuses statement to '0' (just as a test), and it happily sets the register to 0:
Code:

Configuration Fuses:
   Word  1: 0000   LP NOIESO NOFCMEN
   Word  2: 1E1E   BROWNOUT NOWDT BORV21 PUT WDT32768
   Word  3: 8600   PBADEN LPT1OSC MCLR
   Word  4: 00B1   STVREN NODEBUG NOLVP NOXINST BBSIZ4K
   Word  5: C00F   NOPROTECT NOCPD NOCPB
   Word  6: E00F   NOWRT NOWRTD NOWRTC NOWRTB
   Word  7: 400F   NOEBTR NOEBTRB


You have something else getting in the way. Are you _sure_ your programmer is setup to read the fuses from the incoming file?.
Are you sure you don't have a #ROM somewhere in the code, or another #fuses line being loaded?.

The problem is _not_ with the compiler.

Best Wishes
magic_mauve



Joined: 05 Apr 2011
Posts: 12

View user's profile Send private message

PostPosted: Thu Sep 15, 2011 8:15 am     Reply with quote

Thank you. I got the same results as you and I have now found the problem.

I was using

#use DELAY(crystal=16000000)

when I changed this to:

#use DELAY(clock=16M)

H4 gets set correctly.

Many thanks for your help.
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