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

PIC18F25K22 clock problem
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
picprogrammer12345



Joined: 27 Jun 2013
Posts: 22

View user's profile Send private message

PIC18F25K22 clock problem
PostPosted: Thu Mar 06, 2014 9:09 am     Reply with quote

I am using a PIC18F25K22 chip.
I am using a 20MHz external oscillator.

The fuse setup is as follows:
#fuses HSH,NOPLLEN,NOMCLR,NOWDT,NOLVP,PROTECT,DEBUG //Fuses configuration
#use delay(clock=20000000) //Clock Used is 20 MHz


The software works perfectly fine. But after sometime the code starts to work very slowly.
There is a delay of 3sec in the code before printing information on the LCD. It starts to become a delay of around 15 to 20 second but the software is still working but it is very very slow.
Can someone guide me to right direction on what is happening?
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Thu Mar 06, 2014 9:33 am     Reply with quote

The HSH and HSM fuses are for crystals. For an external oscillator, you need either ECH (external clock, high power) or ECH_IO (same as ECH but your PIC's OSC2 line becomes available for program IO control).
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 06, 2014 10:04 am     Reply with quote

One possible problem is that the fuse 'debug' is enabled. When enabled, it'll set fuses to what IT wants, not necessarily what YOU need.

Also if using MPLAB, be sure the compile is done in .release' mode not the factory default of 'debug'. Again, that can cause 'fun'.

I also set fuse 'PUT' to enable the 'Power Up Timer' just to help the PIC do 'housekeeping'..

hth
jay
picprogrammer12345



Joined: 27 Jun 2013
Posts: 22

View user's profile Send private message

PostPosted: Thu Mar 06, 2014 12:39 pm     Reply with quote

The clock I am using is ECS-200-20-46X
Datasheet
http://www.ecsxtal.com/store/pdf/HC-46X.pdf

I think EC would be for a clock that doesnt use both CLKIN pin and LCKOUT pin. But for this I am using both.
Also software is working at first sometimes works for hours. It randomly starts to delay the entire code.

I am using PIC compiler version 4.129 not MPLAB.
picprogrammer12345



Joined: 27 Jun 2013
Posts: 22

View user's profile Send private message

PostPosted: Thu Mar 06, 2014 12:44 pm     Reply with quote

On the datasheet of PIC18F25K22 for the oscillator and clock it say on page 35:

HS Oscillator mode offers a Medium Power (MP) and a
High Power (HP) option selectable by the FOSC<3:0>
bits. The MP selections are best suited for oscillator
frequencies between 4 MHz and 16 MHz. The HP
selection has the highest gain setting of the internal
inverter-amplifier and is best suited for frequencies
above 16 MHz. HS mode is best suited for resonators
that require a high drive setting.

FIGURE 2-6: QUARTZ CRYSTAL
OPERATION (LP, XT OR
HS MODE)
Note 1: A series resistor (RS) may be required for
quartz crystals with low drive level.
2: The value of RF varies with the Oscillator mode
selected (typically between 2 Mohm to 10 Mohm

If you want to look at the figure please download datasheet. Could it be cause of the resistance? Right now the clock is connected directly to the PIC chip with 22pF caps.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 06, 2014 12:48 pm     Reply with quote

Quote:
I am using a 20MHz external oscillator.

It's the terminology. In the electronics world, a "cystal" is what you
show in your data sheet. The package contains the crystal only.

An "oscillator" is a package which contains both a crystal and the
oscillator circuit inside it. It requires power and ground to run it.
http://www.ecsxtal.com/store/pdf/ecs-5725-5718r.pdf
picprogrammer12345



Joined: 27 Jun 2013
Posts: 22

View user's profile Send private message

PostPosted: Thu Mar 06, 2014 12:50 pm     Reply with quote

PCM programmer wrote:
Quote:
I am using a 20MHz external oscillator.

It's the terminology. In the electronics world, a "cystal" is what you
show in your data sheet. The package contains the crystal only.

An "oscillator" is a package which contains both a crystal and the
oscillator circuit inside it. It requires power and ground to run it.
http://www.ecsxtal.com/store/pdf/ecs-5725-5718r.pdf


Thanks for the clarification. I know my datasheet says for sure the clock is a quartz crystal. So i believe my fuses are set right. Could it be because the reistance is not there, the clock fails randomly? Or is it something else I am not seeing?

Thanks all for the replies
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Thu Mar 06, 2014 12:50 pm     Reply with quote

For future reference, an oscillator is taken to mean a self contained unit that generates a high stability clock signal on its own. A crystal does not.

Your crystal is a series crystal. That's a problem.
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Thu Mar 06, 2014 12:51 pm     Reply with quote

What you have is a crystal, not an oscillator.
A crystal is a 'resonant' device.
A crystal makes an oscillator, when driven by a circuit that amplifies and inverts the signal coming from it's output, and feeds it back to the input.
Yes it uses HSH.
An oscillator is a module that contains the amplifier as well, and just gives a clock output.
You only have an 'oscillator', when connected to the amplifier in the PIC.

I don't think your problem is clock related.

Without seeing your code, it is difficult to have any idea. However something internal in the code, that is sitting waiting for something to happen, and an event (floating pin, or specific signal pattern for example), that changes the wait.
picprogrammer12345



Joined: 27 Jun 2013
Posts: 22

View user's profile Send private message

PostPosted: Thu Mar 06, 2014 12:56 pm     Reply with quote

Alll the program does is checks analog pin for high voltage. When the adc pin detects high voltage , the code enters a loop and stays there until the pin is high.

What happens is sometimes when i am constantly supplying high and low to the ADC pin, at certain point it gets stuck at high detected and gets stuck there even after i remove the high voltage line.
After around 10-20 seconds it says high not detected. Then if I give the high again, it says high detected after another 10-20 seconds or so.

How can it happen when its going through the same loop which worked for an hour?
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Thu Mar 06, 2014 12:58 pm     Reply with quote

What is driving the pin?.
What ensures the signal does not go outside the range Vss to Vdd?.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 06, 2014 1:04 pm     Reply with quote

Newguy,
I don't think he has a series crystal, because here is the ECS part
numbering guide:
http://www.ecsxtal.com/store/pdf/partnumber4.pdf
He said his part number is:
Quote:
The clock I am using is ECS-200-20-46X

The part numbering guide shows this is a 20pf parallel mode crystal.
Here is a series crystal, and it has the "S" in the part number:
http://www.digikey.com/product-detail/en/ECS-200-S-4X/X1075-ND/827567

---------------
Edited to address post to Newguy


Last edited by PCM programmer on Thu Mar 06, 2014 1:21 pm; edited 1 time in total
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Thu Mar 06, 2014 1:10 pm     Reply with quote

The datasheet he linked to mentioned it was a series crystal. That was as far as I dug.

As Ttelmah has said, he probably has a much different issue masquerading as a clock problem.
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Thu Mar 06, 2014 1:21 pm     Reply with quote

I too only looked at the sheet he linked to.
However it going wrong after a time, to me suggests something else is 'afoot'.

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 06, 2014 1:22 pm     Reply with quote

Quote:
The software works perfectly fine. But after sometime the code starts to work very slowly.

What's your CCS compiler version ?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
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