# Timer1 not running on PIC16F628

I have this little project that requires exact clock so I'm using 32768 Hz quartz on RB6 & RB7 on my PIC16F628. Both pins are grounded using 33 pF capacitors.

My code that configures the timer1 is as follows (HI-TECH C compiler):

TRISA = 0b11100011; //x3F;      // bit=0 - output; bit=1 - input
TRISB = 0b11110000; //x3F;      // bit=0 - output; bit=1 - input
nRBPU = 1; //affects inputs only
TMR1ON = 0;     // Disable Timer 1
T1CKPS1 = T1CKPS0 = 0;   // 1:1 Prescale value
T1OSCEN = 1; //start tmr1 oscillator
TMR1CS = 1;  //0: internal clock; 1: wait external clock
nT1SYNC = 0; //sync by external clock
TMR1 = 0x8000;
PEIE = 1;
TMR1IE = 1;
ei(); //sets GIE
//T1CON = 0b00001111;
TMR1ON = 1;     // Enable Timer 1


The config bits:

__CONFIG(WDTE_OFF & MCLRE_ON & PWRTE_ON & BOREN_OFF & LVP_ON & FOSC_INTOSCIO & CP_OFF & CPD_OFF);


The problem - it never runs. I have an LED in the ISR that should be lighted up. Also I used an oscilloscope to investigate. Changed the capacitors. Tried another crystal. Tried all possible approaches. Nothing helped.

• You used the Internal Oscillator, but you should have used the Low Power Oscillator in the Configuration bits – m.Alin Apr 11 '12 at 19:20
• @m.Alin, my guess is you mean "FOSC_LP" mode /which demands crystal on ra6 and ra7/ but isn't this mode about the chip's main oscillator? My goal is to use the internal RC oscillator as a chip clock and timer1 oscillator as a timer1 clock. – Nedko Apr 11 '12 at 21:33
• @Nedko So is there a reason why you're not using the 32768 Hz quartz as your main oscillator? – m.Alin Apr 12 '12 at 10:07
• I wish to have more processing power - with 4mhz the clock is 1 uS; with 32768 KHz - it's 122 uS. Well it seems that I will end up using 32KHz or 4MHz as the main oscillator. – Nedko Apr 12 '12 at 10:38