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

SOSC not working with a 32.768KHz crystal

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



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

SOSC not working with a 32.768KHz crystal
PostPosted: Mon Nov 25, 2019 9:59 am     Reply with quote

Scenario:
CCS v5.091
MPLAB X IDE v5.30
Device PIC24FJ1024GB606

With this setup Timer 1 runs but too slow, should count 1200 pulses in 300 seconds and is counting 1200 pulses in 474 seconds.

Code:

#include <24FJ1024GB606.h>
#fuses NODEBUG
#device ICD=1

#use delay(internal=32MHz,USB_FULL,ACT)
#fuses SOSC_LOW,SOSC_SEL

//In main I set Timer 1 like this
setup_timer1(TMR_EXTERNAL_SOSC|TMR_DIV_BY_1|TMR_CONTINUE_IDLE,8191);
ENABLE_INTERRUPTS(INT_TIMER1);


With the following code Timer 1 doesn't get any clock
Code:

#include <24FJ1024GB606.h>
#fuses NODEBUG
#device ICD=1

#use delay(internal=32MHz,USB_FULL,ACT)
#fuses SOSC,SOSC_LOW,SOSC_SEL

//In main I set Timer 1 like this
setup_timer1(TMR_EXTERNAL_SOSC|TMR_DIV_BY_1|TMR_CONTINUE_IDLE,8191);
ENABLE_INTERRUPTS(INT_TIMER1);


And in both cases the SOSC doesn't oscillate at all; I tested with and oscilloscope with a x10 tip in AC mode.
I have two 27pF to ground from each pin.
Any idea why the SOSC is no running?
_________________
Electric Blue
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Mon Nov 25, 2019 11:35 am     Reply with quote

I seems like is working but I can't get the signal wave in my oscilloscope even with a 10x probes, as soon as I touch the SOSCO it stop working.
_________________
Electric Blue
temtronic



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

View user's profile Send private message

PostPosted: Mon Nov 25, 2019 11:43 am     Reply with quote

I don't use that PIC, but I'd read the datasheet about what the design requirements for the xtal and caps are. Usually it's xx pfd for the ENTIRE osc section, so you have to add in PCB traces, layout, etc. Say the 'spec' say 20pfd. There could be 5pfd of 'board' capacitance, so 15pfd caps should be used.

If the PIC board and PSU is not grounded to the same ground as the scope, if could stop the oscillator as you're adding a LOT of C to the circuit.

Also, perhaps the xtal is not the correct 'cut'. You could use xtal, caps and a CMOS inverter (4069 ?) and test.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19555

View user's profile Send private message

PostPosted: Mon Nov 25, 2019 1:06 pm     Reply with quote

From the data sheet:
Quote:

When
Low-Power mode is used, care must be taken in the
design and layout of the SOSC circuit to ensure that the
oscillator starts up and oscillates properly. PC board
layout issues, stray capacitance and other factors will
need to be carefully controlled in order for the crystal to
operate.


You are selecting low power mode.

What is the quoted load capcitance of your crystal?. In low power
mode they recommend 6 to 9pF crystals are used.
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Mon Nov 25, 2019 1:09 pm     Reply with quote

At this moment is running ok but I can't see the wave in the oscilloscope.
The probe ground is connected half of an inch away from the oscillator, the PCB has 4 ground planes, one per layer.

I'm going to try to decrease the C values and see if stay running with the oscilloscope probe connected to it.
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19555

View user's profile Send private message

PostPosted: Mon Nov 25, 2019 1:49 pm     Reply with quote

A scope probe is typically 30pF. If your crystal is already overloaded
with a bit too much capacitance on the board, with low drive, this just
kills the oscillation. Normally the OSC out pin is slightly less sensitive
to extra capacitance than the in pin.
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Mon Nov 25, 2019 3:01 pm     Reply with quote

I have two 27pF to ground from each pin.

The tiny cylindrical clock crystal is low power right?
Or should use high power mode?
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19555

View user's profile Send private message

PostPosted: Tue Nov 26, 2019 12:10 am     Reply with quote

Ugh!...
What is the rated capacitance of your crystal?.
Understand that these capacitors should be twice the rated capacitance
for the crystal, less the sum of the pin & track capacitance.
So if your crystal is designed for (say) 12pF load capacitance, and
your PCB tracks have perhaps 5pf capacitance, then the capacitors
would need to be:

(12*2)-(5+4) = 15pF

If your tracking is even fractionally long, this will drop.

Now typical watch crystals are rated for load capacitances between
perhaps 6pF and 12pF. The former type is designed to run without
any added capacitance into circuits like the PIC & RTC chips. This is
much lower than crystals like the 4MHz used for the main oscillator,
These normally require capacitances like 20pF.
Typically the PIC pins will have perhaps 3 to 4pF capacitance.

I suspect you are overloading your crystal, possibly already having
perhaps twice the capacitance you really want....
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