In many case (but random) when PIC18F8722 go to IRQ handler, some Ram variables changes their value with dramatic conseguence in the flow of process. This is the source of IRQ :
'************************************************* *********
' Assembly language INTERRUPT handler
Asm
GlbInt
;^^^^^
; Save the state of critical registers
;************************************************* *************************************************
; Select How Interrupt Occur
MOVWF wsave ; wsave is W
MOVFF STATUS, ssave ; ssave is STATUS
MOVFF FSR0, fsave ; fsave is BSR
MOVFF FSR1, fsave1
MOVFF FSR2, fsave2
MOVFF BSR, bsave
;
RXF btfsc _RC1IF
call _RxIRQ ; Routine Interrupt EUSART1 Receiver
;
T0F btfsc _TMR0IF
call _timer0IRQ ; Routine Interrupt Timer0
;
T1F btfsc _TMR1IF
call _timer1IRQ ; Routine Interrupt Timer1
;
;************************************************* *************************************************
; Restore
finished
;
MOVFF bsave, BSR
MOVFF fsave2, FSR2
MOVFF fsave1, FSR1
MOVFF fsave, FSR0 ; Restore BSR
MOVFF ssave, STATUS ; Restore STATUS
MOVF wsave, W ; Restore WREG
RETFIE
;
EndAsm
'
asm
'************************************************* ********
' Those the IRQ variables :
'************************************************* ***************
'Interrupt used variables
wsave var byte $100 system ' Saves W
ssave var byte $101 system ' Saves STATUS
fsave var word $102 system ' Saves FSR0
fsave1 var word $104 system
fsave2 var word $106 system
bsave var word $108 system
Can I make something ???? Thank's so much. Pheraps isn't valid save stack routine for this MCU. I'ved copy this for a 16f877 MCU and adaptate to 18f8722.
Sorry for language.
Bookmarks