Hi, I am trying to move my PicBasic Pro programs from 16F876 to 18F2525. I am unclear as to the difference in context saving/restoring with interrupts. In the PicBasic Pro manual it says that:
"If a 14-bit core PICmicro MCU has more than 2K of code space, an
interrupt stub is automatically added that saves the W, STATUS and
PCLATH registers into the variables wsave, ssave and psave, before
going to your interrupt handler. Storage for these variables must be
allocated in the BASIC program:"
wsave var byte $20 system
wsave1 var byte $a0 system ‘ If device has RAM in bank1
wsave2 var byte $120 system ‘ If device has RAM in bank2
wsave3 var byte $1a0 system ‘ If device has RAM in bank3
ssave var byte bank0 system
psave var byte bank0 system
My original intrrupt rountine, which seems to have worked fine for years had the following code in an included file containing my inerrupt rountines in assembly language.
;======= System variables: ======================
wsave VAR BYTE $70 system
ssave VAR BYTE bank0 system
psave VAR BYTE bank0 system
I had no context saving intering the routine as I believe PBP is doing this for me.
Upon exit I have the following:
intsrvx bcf STATUS,RP0 ;select Bank 0
bcf STATUS,RP1
movf psave, W ;restore the state of everything
movwf PCLATH
swapf ssave, W
movwf STATUS
swapf wsave, F
swapf wsave, W
retfie
The interrupts I am using are Timer1(16F876) and Serial Recieve. In my intrrupt rountine I am writing to EEProm too.
As I said I believe all is well here. My question is, can anyone recommend what will be required to do for the 18F2525 to provide the context save/restore to accomplish the same thing? Do I supply the context saving as well as restoring. Does anyone have any recommended methods?
Thanks for any help you can provide, Bob
Bookmarks