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 support@ccsinfo.com

#FUSE HSPLL problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
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: 19430

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