You need to enable peripheral interrupts to get TIMER1 interrupts to work. Using your syntax, you need to add INTCONbits.PEIE = 1; --- Peter Moreton wrote: > Hi, > > I'm making some progress with a simple clock > application, but cannot get > TIMER1, with a 32.768Khz watch crystal on the > T1OSO/T1OSI pins to work > at all. The code below works if I un-comment the > TIMER0 parts marked > "A", but when I use my TIMER1 code (marked "B"), the > timer overflow > interrupt never gets called. My oscilloscope shows > the 32.768khz xtal is > oscillating nicely. > > I'm going back to study the reference manuals now, > but if anyone can > spot the goof-up, I'd be really grateful. > > Peter Moreton > > > > /* > * The following code will flash LEDs connected to > PORTC of a PIC18F452 > microcontroller, using timer1 > */ > > #include > #include > > #define NUMBER_OF_LEDS 8 > > void timer_isr (void); > > static unsigned char s_count = 0; > > /* > * For PIC18xxxx devices, the low interrupt vector > is found at > 000000018h. > * Change the default code section to the absolute > code section named > * low_vector located at address 0x18. > */ > > #pragma code low_vector=0x18 > void low_interrupt (void) > { > // Inline assembly that will jump to the ISR. > _asm GOTO timer_isr _endasm > } > > // Returns the compiler to the default code section. > #pragma code > > /* > * Specifies the function timer_isr as a > low-priority interrupt service > * routine. This is required in order for the > compiler to generate a > * RETFIE instruction instead of a RETURN > instruction for the timer_isr > * function. In addition, it ensures that PROD > special function register > * will be saved. > */ > > #pragma interruptlow timer_isr save=PROD > > void timer_isr (void) > { > static unsigned char led_display = 0; > > // Clear the TMR1 interrupt flag to avoid > processing the same > interrupt multiple times > > //INTCONbits.TMR0IF = 0; // A: > Original TIMER0 reset > Interrupt flag code > > PIR1bits.TMR1IF=0; // B: > Couldn't find > "INTCONbits.TMR1IF", maybe this is right? > > s_count = s_count % (NUMBER_OF_LEDS + 1); > led_display = (1 << s_count++) - 1; > PORTC = led_display; > } > > void main (void) > { > int count; > > TRISC = 0; > PORTC = 255; > > // Enable the TMR1 interrupt, setting up the timer > as an external > 32.768 khz, 16-bit clock > > // OpenTimer0 (TIMER_INT_ON & T0_SOURCE_INT & > T0_16BIT); > // A: Original Timer0 code that works OK > > OpenTimer1 (TIMER_INT_ON & T1_OSC1EN_ON & > T1_PS_1_1 & T1_SYNC_EXT_OFF > & T1_16BIT_RW); // B: > > INTCONbits.GIE = 1; // Enable global > interrupts > > while (1) > { > ; > } > > } > > -- > http://www.piclist.com hint: The list server can > filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics __________________________________ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics