Kamikaze47 is right.
There is definately a problem using PAUSE in an ASM interrupt.
Pause uses 2 internal PBP variables. (R0 and R1). So if, another PBP statement that uses either R0 or R1 gets interrupted, the interrupt routine will change those values and the main program will get confused.
It's possible to have a pause in the interrupt, IF you save both of the system vars first, then restore them when the int is finished.
In that case, toms example would look like this...
Code:
R0save VAR WORD
R1save VAR WORD
asm
int_handler
; Save Resisters ;
IF (CODE_SIZE <= 2)
movwf wsave ; Save W Register into wsave
swapf STATUS,W ; Save STATUS Register into ssave
clrf STATUS
movwf ssave
movf PCLATH,W ; Save PCLATH Register into psave
movwf psave
movf FSR,W ; Save FSR Register into fsave
movwf fsave
endif
endasm
R0save = R0
R1save = R1
high LED
pause 100
low LED
R1 = R1save
R0 = R0save
asm
; Restore Resisters ;
movf fsave,W ; Restore FSR Resister
movwf FSR
movf psave,W ; Restore PCLATH Resister
movwf PCLATH
swapf ssave,W ; Restore STATUS Resister
movwf STATUS
swapf wsave,F ; Restore W Resister
swapf wsave,W
bcf INTCON,1
retfie
endasm
But then, like tom says ... "it is not advisable to use delays in interrupt"
<br>
Bookmarks