PDA

View Full Version : Weird Oscillator Problem



eoasap
- 16th December 2005, 23:47
14.7546 MHz crystal
PIC18LF8722
MPLAB v7.22 (with config fuse set to HS)


DEFINE osc 16
asm
__CONFIG _CONFIG1H, _OSC_XT_1H
endasm


works perfect, display to LCD fine, but delay is off (delay 100 is has about a 500ms delay). If i change the above fuse to:

asm
__CONFIG _CONFIG1H, _OSC_HS_1H
endasm

then speed seems normal, but output to LCD is messed up, characters missing, different line display, etc..

Any ideas what's wrong?

Charles Linquis
- 17th December 2005, 04:52
My suspicion is that when you have the oscillator type set to 'XT' and you have such a high frequency crystal, you are actually running at a sub-multiple of the actual frequency. Since the PIC is running so slow, the LCD has no trouble responding.

When you set the oscillator type to 'HS' it then runs at the true crystal frequency (14.7xMhz), and the LCD can't keep up.

Add the lines

DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 200

To the top of the program, the LCD will work and your program will run fast.

eoasap
- 17th December 2005, 14:21
that worked, but i think maybe the PLL is enabled becuase even a pause 2000 seems like about 1/2 second or so (i dont have a scope to measure the exact frequency). i dont see how
__CONFIG _CONFIG1H, _OSC_XT_1H
would set the HS+PLL but it definately seems faster than ~15Mhz.


lcdout cmd, clr 'clears the LCD screen
pause 200 ' if this pause is not here, it will just print line1 as blank
lcdout cmd, line1, "14.7456 MHz"
pause 200 ' if this pause is not here, it will print a blank screen on line 2
lcdout cmd, line2, " Crystal Test"
pause 4000 ' this is about a 1 second pause