Searching \ for 'The Corrupted Interrupt' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/ints.htm?key=interrupt
Search entire site for: 'The Corrupted Interrupt'.

Truncated match.
PICList Thread
'The Corrupted Interrupt'
1997\11\05@044226 by x93celsnak

flavicon
face
I believe I have a bug in my ISR (PIC 16c72).
I am willing to give-up an arm for this one:

My compare mode software interrupt, somewhere, is corrupting something!
(My LCD that I update prints mega-rubbage when this interrupt is enabled)
All I want is to toggle a pin, when the compare interrupt happens.

;ISR SaveContext
;WTEMP, STATTEMP, FSRTEMP and PCLTEMP are all pre-defined registers.
;I am assuming these are mirrored in both Banks? Jeff?

               movwf   _WTEMP          ; = stored W Register
               swapf   STATUS,0        ;put status in W,storing last bank
               bcf     STATUS,5        ;clear to bank0
               movwf   _STATTEMP       ; =the whole status register
               swapf   FSR,0           ; Into W you go.
               movwf   _FSRTEMP        ; =the whole fsr register
               swapf   PCLATH,0        ; into W
               movwf   _PCLTEMP        ;save PCLATH
               clrf    PCLATH          ;unconditionally in lowest page

               btfss   PIR1,2          ;bit-test for compare interupt,else
               goto    restorec        ;return if ccp1if is clear!!! ,else
;Toggle Routine:
               bcf     T1CON,0         ;Stop the Timer1
               bcf     PIR1,2          ;Clear the Interrupt Flag
               clrf    TMR1L           ;Clear the TIMER1 register
               clrf    TMR1H
               bsf     T1CON,0         ;Timer1 back ON,(bit0 is tmr1on)
               btfss   _PINSTATE,0     ;test, skip next if HIGH
               goto    SetHigh         ;else set freq_pin High
;SetLow
               bcf     portb.0         ;else Set pin LOW
               bcf     _PINSTATE,0     ;Clear pinstate flag
               goto    restorec
SetHigh
               bsf     portb.0         ;Set High
               bsf     _PINSTATE,0     ;set pinstate flag

restorec                        ;restore context
                               ; i0 = stored W Register
                               ; i1 = the whole status register
                               ; i2 = the whole fsr register
               bcf     STATUS,5        ;clear to bank0
               movf    _PCLTEMP,0      ;into 0=W register
               movwf   PCLATH          ;restore PCLATH
               movf    _FSRTEMP,0      ;get FSR into W
               movwf   FSR             ;restore FSR
               swapf   _STATTEMP,0
               movwf   STATUS
               swapf   _WTEMP,1                ;"1" should be "F"
               swapf   _WTEMP,0
               RETI

1997\11\05@054240 by Andrew Warren

face
flavicon
face
Dave Celsnak <spam_OUTx93celsnakTakeThisOuTspamwmich.edu> wrote:

{Quote hidden}

Dave:

If you're going to use SWAPFs to save your FSR and PCLATH values,
you also need to use SWAPFs when you restore them.

Personally, I'd leave the "restore" code alone and change the "save"
code to:

   movwf   _WTEMP
   swapf   STATUS,0
   bcf     STATUS,5
   movwf   _STATTEMP
   movf    FSR,0
   movwf   _FSRTEMP
   movf    PCLATH,0
   movwf   _PCLTEMP

-Andy

=== Andrew Warren - .....fastfwdKILLspamspam@spam@ix.netcom.com
=== Fast Forward Engineering - Vista, California
=== http://www.geocities.com/SiliconValley/2499

1997\11\05@114520 by Bob Fehrenbach

picon face
Andrew Warren <fastfwdspamKILLspamIX.NETCOM.COM> wrote:
>Dave Celsnak <.....x93celsnakKILLspamspam.....wmich.edu> wrote:

  <Snip context save and restore stuff>

Another possible source of misbehavior can occur if you have a
 "goto interrupt_service_routine"    at h'04'.

If you are executing background software in page 1 and generate an
interrupt, execution will go to h'04' but PCLATH will still point
to page 1.  The goto instruction will not take you where you want
to go if the ISR is in page 0.

Been there, did that.


--
Bob Fehrenbach    Wauwatosa, WI     EraseMEbfehrenbspam_OUTspamTakeThisOuTexecpc.com

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...