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

How do I test PIC external Oscillator with scope?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Johannes



Joined: 05 Dec 2003
Posts: 10
Location: Port Elizabeth, South Africa

View user's profile Send private message Visit poster's website

How do I test PIC external Oscillator with scope?
PostPosted: Tue Dec 09, 2003 1:15 am     Reply with quote

Hi All,

I am trying to test the oscillator of a PIC16F877 with my digital oscilloscope. The pic is configured with a 20MHz x-tal and two 33pf capacitors. As soon as I connect my scope to the oscillator inputs of the PIC, the Oscillator stops running. I gues that the scope is loading the oscillator to much. How should I connect the scope to the PIC to verify the oscillator speed without disturbing the PIC's operation?

Thanking you,
Johannes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 09, 2003 2:34 am     Reply with quote

Which oscillator pin are you putting the probe on ?

Try putting it on the OSC2 pin. On a 40-pin DIP, that
would be pin 14. That pin is the output driver of the
oscillator.

If you do this, does it still shut off ? If so, try these things:

1. Are you using a 10x probe or a 1x ? You should use a 10x.

2. Are you certain that you're using HS mode ?
I don't know if a 20 MHz crystal would oscillate at XT mode,
since I've never tried it. But, I know that XT mode has much
less drive than HS mode. It's much easier to load down the
oscillator pins in XT mode, and shut down the oscillator.
If you're using XT mode, change it to HS.

3. Possibly, you should reduce the capacitor size to 22 pf, at
least as a test. I know that if you follow the formula for
calculating the load capacitor size, it will say to use either
27 pf or 33 pf caps. But I typically use 22 pf, perhaps just
out of habit. Anyway, it's worth a try.
Johannes



Joined: 05 Dec 2003
Posts: 10
Location: Port Elizabeth, South Africa

View user's profile Send private message Visit poster's website

PostPosted: Tue Dec 09, 2003 5:02 am     Reply with quote

Thanks for the info, the PIC is not shutting off anymore. I am not sure what caused the circuit to shut off before.

However I still don't get the right frequency.
I have the scope on 10x and measure from OSC2 and the scope GND on the the PIC Vss.
The PIC is configured to run in HS mode.

According to the scope the period for one oscillator cycle is 240 us that is 4.1667 kHz.

Could this be that I don't connect the scope right to the PIC. Surely the period for one cycle should be 50ns (20MHz).
Ttelmah
Guest







PostPosted: Tue Dec 09, 2003 6:17 am     Reply with quote

Johannes wrote:
Thanks for the info, the PIC is not shutting off anymore. I am not sure what caused the circuit to shut off before.

However I still don't get the right frequency.
I have the scope on 10x and measure from OSC2 and the scope GND on the the PIC Vss.
The PIC is configured to run in HS mode.

According to the scope the period for one oscillator cycle is 240 us that is 4.1667 kHz.

Could this be that I don't connect the scope right to the PIC. Surely the period for one cycle should be 50ns (20MHz).


The amount you are 'off', is massive. I have seen the oscillator run at a sub frequency (but normally only perhaps 2.5MHz), where the crystal is overdriven, and slightly overdamped. A series resistor to the crystal, may prevent this. However your amount is so far out, as to be silly. Are you dead sure the capacitors are 33pF?. You might expect something like this, if a 33nF was fitted instead!. 33pF, is a slightly large value for most 20MHz crystals. You should check the specification of the crystal you have fitted. Generally, the larger types, may require 30pF, but some of the small HC49U types only require 12pF. Remember also, this is the total 'load' capacitance, so your capacitor is paralleled with the pin capacitance, and that of any local tracks. This is why 27pF, is a common value to use for crystals requiring 30pF load.
The crystal is seen as a simple 'filter' network, with the highest 'pass', at it's fundamental frequency. Normally the crystals used, are 'overtone' crystals, so unless the rest of the circuit is right, there can be a tendency to oscillate on the fundamental, rather than at the required overtone. Your frequency though is so low, that you have to think in terms of something massively reducing the gain at higher frequencies. Hence the comment about the capacitors. Given the low gain that may be occuring, the oscillator may not be reliable (which could explain the tendency to stop when the scope probe is added).
For 'test' purposes, try programming one of the CTC outputs to run at a known divider, and output this for a frequency test (avoids the need to load the oscillator).
A low oscillation frequency like this, might also be seen if the crystal had been damaged by soldering, and is behaving just as a high value resistor. Combined with the input capacitor, this could give frequencies like this.

Best Wishes
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Dec 09, 2003 7:06 am     Reply with quote

Quote:

I don't know if a 20 MHz crystal would oscillate at XT mode,
since I've never tried it.


I've done that before Smile with resonators. A 20MHz won't work with the XT nor will a 4MHz work with HS. In one of the cases, a touch of the circuit seemed to get it going.
Johannes



Joined: 05 Dec 2003
Posts: 10
Location: Port Elizabeth, South Africa

View user's profile Send private message Visit poster's website

PostPosted: Tue Dec 09, 2003 7:24 am     Reply with quote

Ok, I took out my PICdem 2 Plus Demo Board and tested the same thing. The only difference is that now I use a 4MHz x-tal module. I measure with the scope between OSC2 & GND, eureka. The cycle time is exactly 250ns ( 1/250ns = 4MHz).

The other board runs perfect. I don't have any problems with it. I just wanted to test the oscillator speed as a matter of interest. It obviously is loaded too much when I try to connect the scope giving me false readings. I must still try to use 27pf caps.
chas
Guest







Possible aliasing
PostPosted: Tue Dec 09, 2003 9:20 am     Reply with quote

Which digital scope are you using? What is the sampling rate of the scope? Is there a chance that you are experiencing some sort of under sampling aliasing? Your scope must sample at least 2x the frequency of interest, and preferrably higher. Some scopes with lower sampling rates play tricks by shifting the sampling clock on repetative waveforms to sort of build up the waveform.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Tue Dec 09, 2003 10:19 am     Reply with quote

Johannes,

I guess that if you are checking your xtal frequency is because something wrong. Did you check your #fuse configuration to be sure NOLVP is present ? Some time ago I spent half a day to realize that !
Code:

#fuses HS,NOWDT,PUT,BROWNOUT,NOPROTECT,NOLVP,NOCPD,NOWRT


Regards,

Humberto
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

Re: Possible aliasing
PostPosted: Tue Dec 09, 2003 1:27 pm     Reply with quote

chas wrote:
Which digital scope are you using? What is the sampling rate of the scope? Is there a chance that you are experiencing some sort of under sampling aliasing? Your scope must sample at least 2x the frequency of interest, and preferrably higher. Some scopes with lower sampling rates play tricks by shifting the sampling clock on repetative waveforms to sort of build up the waveform.


If you have a slow scope you could write a little program to generate a low frequency square wave using the PIC's hardware counters, and measure the resulting square wave to be sure the xtal is running OK.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Johannes



Joined: 05 Dec 2003
Posts: 10
Location: Port Elizabeth, South Africa

View user's profile Send private message Visit poster's website

PostPosted: Wed Dec 10, 2003 11:26 pm     Reply with quote

Thanks all for the info, the problem seems to be my scope. I took my board to a friend of mine and we tested it on a 100MHz scope. All measured as expected. Now I will have to budget for a new scope. Any ideas which scopes are fairly well priced for embedded work?
martin gordon



Joined: 15 Sep 2003
Posts: 6
Location: Edinburgh

View user's profile Send private message

Scope
PostPosted: Thu Dec 11, 2003 3:47 am     Reply with quote

Can recommend an Agilent 54622D, 100MHz analogue 2 channels plus 16 channels digital. It has very long memory 2,000,000 samples so can capture odd pulse sequences.

Problem not low cost

Becarefull look at single shot bandwidth, many units quote large bandwidth or repititive triggers and are useless on infrequent events


Martin
Guest








PostPosted: Thu Dec 11, 2003 4:11 am     Reply with quote

I would reccomend an 100 Mhz Agilent digital scope too.
For embedded work it would be a good idea to choose one of the Agilent Scopes with built in Logic Analyzer. This way you both have two analog inputs and 16 digital inputs.
Guest








PostPosted: Thu Dec 11, 2003 4:15 am     Reply with quote

Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 11, 2003 7:30 am     Reply with quote

I also agree! I have the 54645D. The "MegaZoom" feature comes in real handy when looking at signals over a long time period. Great for debugging communications!
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Dec 11, 2003 9:42 am     Reply with quote

If you are hobbiest without the budget for a new scope check out used gear on EBAY. I picked up an HP 1631A logic analyzer which has 2 analog channels and many digital channels real cheap. That and my old analog scope cover all my uP needs.
_________________
The search for better is endless. Instead simply find very good and get the job done.
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  Next
Page 1 of 2

 
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