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

PIC 18F4550 clock frequency problems

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



Joined: 09 Nov 2006
Posts: 1

View user's profile Send private message

PIC 18F4550 clock frequency problems
PostPosted: Thu Nov 09, 2006 2:34 pm     Reply with quote

I am working with an 18F4550. For the #FUSES, I have selected

#FUSES HS, NOPROTECT, NOLVP, NOBROWNOUT, NOWDT, NOMCLR, NOPUT

With this setting, the PIC is completely unresponsive--it just doesn't work. When I change the #fuses settings to:

#FUSES HS, INTRC, NOPROTECT, NOLVP, NOBROWNOUT, NOWDT, NOMCLR, NOPUT

The PIC works, but the frequency is way too slow for what I need it to do. How do I get it to work at 8MHz frequency?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 09, 2006 3:25 pm     Reply with quote

Here is a test program for the 18F4550 that runs off the internal
oscillator at 8 MHz. I tested this with PCH vs. 3.249 on a PicDem2-Plus
board.
Code:

#include <18F4550.h>
#fuses INTRC_IO, NOWDT, PUT ,BROWNOUT, NOLVP
#use delay(clock=8000000)

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

while(1)
  {
   output_high(PIN_B0);
   delay_ms(500);
   output_low(PIN_B0);
   delay_ms(500);
  }

}
Ttelmah
Guest







PostPosted: Thu Nov 09, 2006 3:31 pm     Reply with quote

Without knowing what type of oscillator you want to use, it'll be a guess. HS, _requires_ an external crystal. If you do not have one, get rid of it. INTRC, implies operation with the internal oscillator.

#FUSES INTRC, NOPROTECT, NOLVP, NOBROWNOUT, NOWDT, NOMCLR, NOPUT
#use delay(clock=8000000)

Should normally give you 8MHz. However on some compilers, you may need to have the line:

setup_oscillator(OSC_8MHZ);

Near the start of the main (the compiler should generate this internally, automatically if the correct 'delay' statement is present, but it is safer to include it yourself).

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