View previous topic :: View next topic |
Author |
Message |
SugarD Guest
|
External Oscillator not working. |
Posted: Tue Dec 29, 2009 1:08 am |
|
|
Hi. I have been using internal oscillator all the time.
Now, I try to use the externally connected oscillator.
However, the either the hardware or software configuration seems to be failing.
The IC has some kind of "switch oscillator" ability.
Trying the MPLAB simulator to see if anything was wrong, I found that
OSCCON register was set to use 1Mhz Internal Osicllator.
Here is the code
Code: |
//Main.c
#include<18F65J90.h>
#include<def_18F65J90.h>
#fuses HS
#use delay(clock = 32768)
//Cumulative Volume Counter
int32 k_factor;
void main(void){
int8 buffer;
while(1);
}
|
The oscillator is wired this way
Code: |
OSC2----------------||------
| |
[ ] |----------
| | |
OSC1----------------||------ |
GND
|
|
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Tue Dec 29, 2009 1:19 am |
|
|
You can't use the HS fuse with the 32,768Hz crystal.
Read the datasheet for the part again closely in the oscillator section.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
SugarD Guest
|
I looked at the data sheet and still can't figure out why |
Posted: Tue Dec 29, 2009 1:52 am |
|
|
and it doesn't work with EC_io fuse either |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Tue Dec 29, 2009 3:52 am |
|
|
I haven't read it in detail but apparently, the 18F65J90 doesn't have an LP mode. So you can't use 32768Hz crystals as the main oscillator.
Are you looking for RTC capability? Use an HS crystal as the main clock, and use a 32kHz crystal as the secondary oscillator.
Alternatively, start the processor using the INTRC fuse, then switch clock sources to T1OSC.
Deriving the clock from T1OSC comes down to using a power managed mode, so you would *have* to first start the processor in one mode, then switch to the 32kHz crystal.
Chapters 2 and 3 from the datasheet will be able to help you out better.
Rohit |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Tue Dec 29, 2009 11:42 am |
|
|
Yea, I didn't look at the datasheet at all either.
but "HS + 32KHz Xtal == No Worky" in my book.
Definitely read the datasheet. What Rohit said is valid and the way a lot of PIC's work.
I recently did a PIC18F46J11 project with 32KHz on T1OSC and it worked great. The new IDLE vs. Sleep modes are awesome.
Cheers,
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
mkuang
Joined: 14 Dec 2007 Posts: 257
|
|
Posted: Mon Jan 04, 2010 10:44 am |
|
|
Does it work if you change the HS to XT ? |
|
|
|