i'm told that with picbasic on parts over 2k, it's not necessary to save them, it's done automatically. only need the restore code. thanks ! dld On Fri, 26 Sep 2003 13:08:38 -0700, Robert Monsen wrote: >When do you save pclath, etc? You have to save them on entry to the isr or >they will change in your mainloop. > > > > >----- Original Message ----- >From: "David Dunn" >To: >Sent: Friday, September 26, 2003 1:01 PM >Subject: [PIC]: Interrupts > > >> I'm at wits end here, for some reason my ISR doesn't seem to be working. >I'm monitoring '_TENTHS' in the main >> program loop and it's not incrementing. Have I missed something obvious ? >What kinds of things would keep the >> TIMER0 interrupt from running ? >> >> Thanks for any ideas. >> >> >> DLD >> >> -------------------------------------------------------------------------- >------------------------------------ >> >> >> wsave var BYTE $020 SYSTEM >> wsave1 var BYTE $0a0 SYSTEM >> wsave2 var BYTE $120 SYSTEM >> wsave3 var BYTE $1a0 SYSTEM >> ssave var BYTE BANK0 SYSTEM >> psave var BYTE BANK0 SYSTEM >> >> GOTO AFTERINT 'Jump past interrupt handler >> >> DEFINE INTHAND isr >> >> asm >> >> isr ; int handler begins here >> >> ;bsf portb,7 >> >> btfsc INTCON,1 ; test if external interrupt (portb.0) >occurred >> goto portbint ; jump over to (portb.0) int handler. >otherwise, just fall thru to TIMER0 handler >> >> timer0int >> >> movlw 0x9e ;reload timer with (256 - >(1)200) + 2 (3a for .1, 9e for .05) >> movwf TMR0 >> incf _TENTHS ;increase TENTHS value >> bcf INTCON,2 ;clear tmr0 interrupt flag >> goto exitisr >> >> portbint >> >> movf TMR1H,W ;read value on timer1 >> movwf _TMR1HI ;store it in some variable >> movf TMR1L,W >> movwf _TMR1LO >> >> clrf TMR1L ;load timer1 with zero again >> clrf TMR1H >> >> bcf INTCON,1 ;clear rb0 interrupt flag >> >> exitisr >> ;restorecode follows here >> movf psave,w >> movwf PCLATH >> swapf ssave,w >> movwf STATUS >> swapf wsave,f >> swapf wsave,w >> >> retfie >> >> endasm >> >> AFTERINT: >> >> ' set up timer0 >> TMR0 = 0 >> INTCON = %00000000 >> OPTION_REG = %11000111 >> INTCON = %10100000 >> >> -- >> http://www.piclist.com hint: The PICList is archived three different >> ways. See http://www.piclist.com/#archives for details. > >-- >http://www.piclist.com hint: The PICList is archived three different >ways. See http://www.piclist.com/#archives for details. David Dunn Digital Racing Products dave@digitalracingproducts.com www.digitalracingproducts.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.