View previous topic :: View next topic |
Author |
Message |
lindermat
Joined: 21 Nov 2011 Posts: 11
|
PIC24F secondary oscillator |
Posted: Sat Dec 17, 2011 7:43 pm |
|
|
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
|
|
Posted: Sun Dec 18, 2011 4:35 am |
|
|
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: 9226 Location: Greensville,Ontario
|
|
Posted: Sun Dec 18, 2011 6:51 am |
|
|
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
|
|
Posted: Mon Dec 19, 2011 9:56 am |
|
|
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: 9226 Location: Greensville,Ontario
|
|
Posted: Mon Dec 19, 2011 10:54 am |
|
|
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: 1615 Location: Central Illinois, USA
|
|
Posted: Mon Dec 19, 2011 12:12 pm |
|
|
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
|
|
Posted: Mon Dec 19, 2011 2:51 pm |
|
|
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: 1615 Location: Central Illinois, USA
|
|
Posted: Mon Dec 19, 2011 2:56 pm |
|
|
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
|
|
Posted: Mon Dec 19, 2011 3:22 pm |
|
|
setup_timer1(TMR_DISABLED) resets all TCON bits, e.g. prescaler settings. You should control TON bit selectively to start and stop the timer. |
|
|
|