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

PIC24F secondary oscillator

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



Joined: 21 Nov 2011
Posts: 11

View user's profile Send private message

PIC24F secondary oscillator
PostPosted: Sat Dec 17, 2011 7:43 pm     Reply with quote

Hi all,
I've searched the forum and can't seem to find an answer to my problem. In my design using a PIC24FJ256GB210 and are using both the primary and secondary oscillator. The primary oscillator (24Mhz crystal) works fine, but I can't get the secondary one to work.

I am using a 32.763kHz tuning fork crystal with 12.5pF load caps. It's connected to the SOSCI and SOCSO pins. The first problem (which may be why it's not working) is that when I probe the pins the signal is small compared to the primary oscillator. It's only about 1 volt p-p. If I don't enable it using the fuse command or just turning on the RTCC I don't get anything so I know the OSCEN bit is being set. I can also change the drive level to low and see the amplitude reduce.

I know the program logic is correct because if I change to the internal osc from sec secondary one it works (but the timeout is much faster)

Any thoughts/suggestions?

Thanks
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Dec 18, 2011 4:35 am     Reply with quote

The secondary oscillator is low power and most likely has a lower level by design. I also guess, it's considerably reduced by a standard oscilloscope probe. You don't use a low capacitance active probe?

I rather suspect a software proble, either in your code or CCS built-in function. Without a compilable code example and knowledge of the CCS version, nothing can be done.
temtronic



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

View user's profile Send private message

PostPosted: Sun Dec 18, 2011 6:51 am     Reply with quote

quick comment.

While I don't use the 24 series, odds are they generally have the same 'internals' as the 18F4550, which I know works fine with the 32KHz xtal as the seconadary .
Probably a 'setup' issue. Try a very simple program(blinking LED 1 Hz rate).Dump the listing,compare to datasheet to confirm the proper bits are being configured.
lindermat



Joined: 21 Nov 2011
Posts: 11

View user's profile Send private message

PostPosted: Mon Dec 19, 2011 9:56 am     Reply with quote

Thanks for the input, I think my problem is that I'm trying to use timer4 and I don't think it can be configured to use the secondary oscillator, only an external pin, or the internal main oscillator.

Is this correct?
temtronic



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

View user's profile Send private message

PostPosted: Mon Dec 19, 2011 10:54 am     Reply with quote

Download the datasheet, look at the 'figures' to see the possible configurations allowed.
Sometimes I find it easier to look at the pictures to see the 'flow' of signals instead of reading pages of specs.( yeah, I'm getting old.....)
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Dec 19, 2011 12:12 pm     Reply with quote

lindermat wrote:
Thanks for the input, I think my problem is that I'm trying to use timer4 and I don't think it can be configured to use the secondary oscillator, only an external pin, or the internal main oscillator.

Is this correct?


it's right in the brief datasheet on PDF page 159 for timer1 and PDF page 162 for the other timers.

Timer1 is the only timer that can operate off the SOSC in normal operation directly UNLESS your system clock is set to SOSC.

To do a quick test, I would turn on Timer1 and set it to use the SOSC and then just flash an LED on IRQ (toggle in ISR)...

Check with a scope if you'd like for accuracy.

If you want 1sec ticks, make sure to set period time accordingly.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
lindermat



Joined: 21 Nov 2011
Posts: 11

View user's profile Send private message

PostPosted: Mon Dec 19, 2011 2:51 pm     Reply with quote

OK, I'll use timer 1 with the external crystal, but I need to start and stop the timer. In the datasheet there is a bit called TON that it looks like I can use to do this, but I can't see how to control it using the CCS functions.

Do I have to access it directly or can I use setup_timer1(TMR_DISABLED) to turn it off? I don't want to reset or reconfigure it, just start and stop it based on events in my program.

Thanks,
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Dec 19, 2011 2:56 pm     Reply with quote

lindermat wrote:
OK, I'll use timer 1 with the external crystal, but I need to start and stop the timer. In the datasheet there is a bit called TON that it looks like I can use to do this, but I can't see how to control it using the CCS functions.

Do I have to access it directly or can I use setup_timer1(TMR_DISABLED) to turn it off? I don't want to reset or reconfigure it, just start and stop it based on events in my program.



you can do either.

Considering the setup_timer functions may or may not do a bit more work than the instruction set supports -- if it doesn't matter, you can just use setup_timer as you've already described.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Dec 19, 2011 3:22 pm     Reply with quote

setup_timer1(TMR_DISABLED) resets all TCON bits, e.g. prescaler settings. You should control TON bit selectively to start and stop the timer.
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