Heinz Czychun wrote: > With Timer 1 disabled I'm able to control Timer 0 effectively with the > INTCON,T0IE bit. Off and on. But when I enable Timer 1, Timer 0 also > starts up and starts interrupting the processor. > > Is this normal? Is it a known problem? Or am I missing something? I'm guessing you aren't checking the IE bits for the disabled interrupts so you get into a infinite interrupt if the IF bit for a disabled interrupt gets set. There are a number of issues with your code, however, before we can look at that. On the good side you seem to have paid attention to banking and did a nice job of documenting bit settings. That puts you ahead of 95% of newbies already. On the flip side there are some serious problems. I didn't look at the code in detail, so here is only what jumped out: > ;***** VARIABLE DEFINITIONS > #define LED_DS1 1 ;LED connected to GP1 This is not a variable at all. You have defined a inline string substitution macro. They can be useful, but should only be used when really needed. If you just want to define a symbolic integer constant, do it right and use EQU. This isn't C. > INT_VAR UDATA_SHR 0x20 Bad idea. I doubt you really need this to be specifically at location 20h, so don't force it there. This happens to work on this chip, but will needless break on other chips that have the unbanked memory in a different location. > RESET_VECTOR CODE 0x000 ;processor reset vector > goto main ;go to beginning of program This particular chip may have only one page, so you can get away with it here, but that doesn't make it a good idea. Use PAGESEL before the GOTO. It won't emit code when the PIC only has a single page, but keeps this from being a lurking bug if the code is ever moved to a larger PIC. > INT_VECTOR CODE 0x004 ;interrupt vector location > goto iServ Never do this. Some code will live at the interrupt vector, so it might as well be the one routine that benefits from being there. In addition, this code is broken on any PIC with more than one page since it relies on PCLATH at the time of the interrupt. And no, using PAGESEL before the GOTO doesn't fix it either because that corrupts PCLATH before the interrupt routine has chance to save it. > main This should be in a separate section so that the linker can place it where it wants to. Right now your code actually forces it to be immediately after the interrupt vector, which makes no sense. > movlw b'00001000' > ; 0------- 1=disabled, no GPIO Pull-ups GPPU: GPIO Pull-ups > ; -0------ 0=falling edge interrupt, INTEDG: Interrupt Edge of GP2 > ; --0----- 0=Internal inst clock (CLKOUT), T0CS: TMR0 Clock Source > ; ---0---- 0=Inc on lo^hi transition on GP2,T0SE: TMR0 Source Edge > ; ----1--- 1=Prescaler assigned to WDT, PSA: Prescaler Assignment > ; -----0-- 001 Prescaler 1:4, PS2-PS0: Prescaler Rate > ; ------0- Bits TMR0 WDT > ; -------0 000 1:2 1:1 > ; 001 1:4 1:2 > ; 010 1:8 1:4 > ; 011 1:16 1:8 > ; 100 1:32 1:16 > ; 101 1:64 1:32 > ; 110 1:128 1:64 > ; 111 1:256 1:128 The comment says 1:4 prescaler but the code says differently. Since the low 3 bits are all one field they should be documented as a single field, not 3 individual bits. > bcf INTCON, GIE This makes no sense in the interrupt routine. Read the manual. GIE is cleared by the hardware when the interrupt is taken, so this is a waste of time. > btfsc INTCON, T0IF > goto ServiceTimer0 > btfsc PIR1, T1IF > goto ServiceTimer1 Here is the cause of the symptoms I think. As I guessed, you are jumping to the interrupt service routines only if the IF bit is set and not checking the IE bit. That means that the timer 0 interrupt service routine will be run even when its interrupt is disabled when you get here for other reasons, which in this case is a timer 1 interrupt. ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist