This is a case of trying too many new things at once. I'm using a PIC18f25k22 (a new device for me) with a standalone, 3-pin 20 Mhz oscillator (also new to me - see photo), and PBP 3 (new to everyone). Right now I'm just starting with a blinky program. I can flash an LED no problem using the internal oscillator, but when I try the external oscillator, the led flashes way too slow--about 20 times too slow to be more precise. If I change the DEFINE OSC statement from 20 to 4 the flashing speeds up, but it is still too slow. It is as if the oscillator is actually working at 1 Mhz instead of 20.

Here is what works (internal oscillator):
Code:
asm
__CONFIG _CONFIG1H, _FOSC_INTIO67_1H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_INTMCLR_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
endasm
OSCCON = 110000; ' 16mHz
DEFINE OSC 16
ANSELA = 0
ANSELB = 0
ANSELC = 0
TRISA = 0
TRISB = 0
TRISC = 0
PORTA = 0
PORTB = 0
PORTC = 0
FLASHLOOP:
HIGH PORTB.4
pause 500
LOW PORTB.4
PAUSE 500
GOTO FLASHLOOP
eND
And here is what works way too slow:
Code:
asm
__CONFIG _CONFIG1H, _FOSC_XT_1H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_INTMCLR_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
endasm
DEFINE OSC 20
ANSELA = 0
ANSELB = 0
ANSELC = 0
TRISA = 0
TRISB = 0
TRISC = 0
PORTA = 0
PORTB = 0
PORTC = 0
FLASHLOOP:
HIGH PORTB.4
pause 500
LOW PORTB.4
PAUSE 500
GOTO FLASHLOOP
eND
I'm hopeful that someone will see an obvious error. I've been playing around with configuration settings and datasheets, but I am far from exhausting all possible options.
Bookmarks