Hi there,
I'd like to have my external 32.768kHz crystal as time base onTMR1 and, in the same time, run the internal oscillator at 4MHz.
Thoretically, this simple code hereunder should blink my LED only when the TMR1IF overflow flag is set.
But...
This code works erratically:
- sometimes the program starts, sometimes not
- commenting the fuses will mostly make the program start almost always
- physically removing the 32.768kHz crystal from my breadboard will change nothing => when the program works, the LED still blinks?!
Setting the FCMEN to OFF will never let the program run which lets me think the 32.768Khz crystal doesn't actually run at all. But le LED blinks?!Code:' ====== FUSES ==================================================================================== ' PIC 16F690 @ __Config _FCMEN_ON &_IESO_OFF &_CPD_OFF &_WDT_OFF &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF &_LP_OSC ' ====== INTERRUPT SERVICE ROUTINE ================================================================ GOTO INIT: ' Just to place ISR at top of program DISABLE ISR: 'if TMR1IF is set (TMR1 has overflown) toggle PORTB.6 'LED PIR1.0 = 0 ' clear TMR1IF overflow flag resume ENABLE ' ====== INITIALIZE =============================================================================== INIT: PAUSE 1000 'circuit settle time ' ====== DEFINES ================================================================================== DEFINE OSC 4 ' ====== REGISTERS ================================================================================ ' 76543210 OPTION_REG = %10000000 ' Pull-Ups disabled OSCCON = %01100000 ' Internal RC set to 4Mhz ANSEL = %00000000 ' Analog inputs Channels 0 to 7 ANSELH = %00000000 ' Analog inputs Channels 8 to 11 INTCON = %11000000 ' INTerrupts CONtrol: GIE is ON, PEIE is ON T1CON = %00111001 ' Timer1 OSC enabled, Timer1 enabled, presc.1:8 PIE1 = %00000001 ' Enable TMR1IF overflow flag ' ====== PROGRAM ================================================================================== ON INTERRUPT GOTO ISR MAIN: goto MAIN: END
What am I missing?



) and the LED stops blinking which is correct.


Bookmarks