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

PIC18F takes forever to start

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







PIC18F takes forever to start
PostPosted: Sat Mar 22, 2008 6:49 am     Reply with quote

SOS guys!
I have just switched to the PIC18F series devices. For a while I was confused with the PLL & the OSC setting but managed to go through it ( or I'm still missing something ...) Here's my problem. I am using a 20MHz crystal with 15pf Cs and played with PLL & CPU div settings to get a stable MCU clock. But everything seems to be futile. Either it takes about 2 minutes to get the PIC started or when it is running already , it hangs somewhere and slows down.
I'm trying to clock the MCU core at 48Mhz although it is not a requirement for the project.
Q1. What is the recommended most stable MCU clock I should use? (I don't need the USB periheral)
Q2. What is the best clcok setting then - there are more than a dozen?
Q3. Do I have the right understanding that I have 48MHz when PLL div 2 & CPU div 5 is set - that is at 20MHz crystal?

I would appreciate your help. I have not experienced such problem with PIC16. By the way , I am using here the brothers PIC18F2550 & 4550.
Matro
Guest







PostPosted: Sat Mar 22, 2008 8:11 am     Reply with quote

Q1. There is no clock frequency more stable than another as long as you stay in the range of the specification
Q2. The best clock setting is the most appropriate to your needs...

Please check the fuses and that the 15pF match with the Xtal datasheet.
You can post your fuses configuration for further help.

Matro
baltazar_aquino



Joined: 16 Mar 2008
Posts: 27

View user's profile Send private message

PostPosted: Sat Mar 22, 2008 8:51 am     Reply with quote

Thanks for prompt reply Matro

Here's the test code
Code:

#include <18F2550.h>
#device adc=8

#FUSES HSPLL  //High Speed Crystal/Resonator with PLL enabled
#FUSES CPUDIV2, PLL5
#use delay(clock=48000000)

void main()
{

     
   ///simple test block - takes forever to start!
   set_tris_b(0);   // all output
   while(1)
   { output_b(0);
     delay_ms(500);
     output_b(0xff);   // fire up LED bank , sometimes hangs
     delay_ms(500);}
   

}

The 15pF seems to be ok according to the data sheet. I use the same value in the PIC16f877a development board I designed. Shocked
drh



Joined: 12 Jul 2004
Posts: 192
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Sat Mar 22, 2008 9:54 am     Reply with quote

The oscillator configuration options for this PIC are quite extensive. After a quick look at the data sheet, DS39632D, I think it shows a 16Mhz xtal as the highest for the mode you are using.
_________________
David
Ttelmah
Guest







PostPosted: Sat Mar 22, 2008 9:58 am     Reply with quote

Add:

#FUSES PUT, NOXINST, USBDIV, NODEBUG, NOLVP, NOWDT

A couple of these are 'optional' at this point, but NOLVP, is essential, unless you have the low voltage programming pins tied to the inactive state.

As has been said, there is really no 'best' frequency, for the master oscillator. Any multiple of 4MHz, up to the maximum supported by the chip. However higher frequencies, mean slightly more power cnsumption in the oscillator, and slightly more RF noise. 4MHz, can be fractionally more 'fussy' to get going, so personally, I tend to recommend 8MHz, or 12MHz.

Best Wishes
baltazar_aquino



Joined: 16 Mar 2008
Posts: 27

View user's profile Send private message

PostPosted: Sun Mar 23, 2008 11:13 am     Reply with quote

I'm still stuck on this. I even tried a lower crystal freq (11.0592mc) under HS mode only (no PLL) but still it won't run. I tested 2 chips already and I have a dozen of this for a target project. My old friend 877a will run the code at 20Mc in a breeze but this one truly disappointing. Crying or Very sad
Ttelmah
Guest







PostPosted: Sun Mar 23, 2008 11:29 am     Reply with quote

How simple is your test code?.
I'd suggest you try something _really_ simple, like a single LED flasher. My suspicion is that something else is hampering your startup, in the code. The chips do run fine, and start just like any other. There are a lot of other things 'different' about these chips.
Put a scope on the oscillator output. Is it starting?.
Have you got brownout enabled?. What voltage?.
Add NOFCMEN, NOPBADEN, and NOIESO to your fuses.

Best Wishes
baltazar_aquino



Joined: 16 Mar 2008
Posts: 27

View user's profile Send private message

PostPosted: Mon Mar 24, 2008 8:38 am     Reply with quote

Ttelmah wrote:
Add:

#FUSES PUT, NOXINST, USBDIV, NODEBUG, NOLVP, NOWDT

A couple of these are 'optional' at this point, but NOLVP, is essential, unless you have the low voltage programming pins tied to the inactive state.



Bullseye! Thanks Ttelmah. It was really the NOLVP fuse that I need + the PUT. But I just noticed one thing. If I use the LF version (18LF2550), I have to use PUT but for the regular 18F2550, I got to use the NOPUT fuse. I don't have time to research for the reason now. Maybe someone out there has. Wow! , I got to work on my MIDI sequencer now. Thanks guys. This forum really works. BTW, Ttlemah, the test code I posted is the LED blink test Wink
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