I'm trying to run a simple program on my PICKit 2 44-pin Demo Board (PIC16F887) that keeps track of the overflows on TIMER1 when it is clocked by the internal 32kHz crystal (see C code below for the CCS complier). The problem I'm having is that I only seem to get two TIMER1 interrupt overflows instead of one every two seconds like I expect. Code works fine if I set up TIMER1 to run off the main processor clock (8MHz).
#include
#use delay(clock=8MHZ)
#FUSES HS,INTRC,NOWDT,NOPUT,NOMCLR,NOPROTECT,NOCPD,NOBROWNOUT,NOIESO,NOFCMEN,NOLVP
int count; //keep track of TIMER1 overflows
#int_TIMER1 void TIMER1_isr(void) { count++; //increment count output_d(count); //display count on LEDs }
void main() { setup_timer_1(T1_EXTERNAL|T1_CLK_OUT); //use low power 32kHz crystal (i.e. T1CON=0x8F) enable_interrupts(INT_TIMER1); enable_interrupts(global); count=0xFF; // turn on all LEDs to start output_d(count); while(1); }