PDA

View Full Version : 18F2480 asm interrupt



Richard Storie
- 5th March 2009, 09:21
Hi All

I have created an assembler interrupt handler for a PIC18F2480 using the following code.

DEFINE INTHAND InterruptHandler
ASM
InterruptHandler
; ********* Serial Framing Error Interrupt *********
btfsc RCSTA,2 ; check if serial framing error interrupt is set
call _FramingError ; call serial framing error subroutine
; ********* Serial Overrun Error Interrupt *********
btfsc RCSTA,1 ; check if serial overrun error interrupt is set
call _OverrunError ; call serial overrun error subroutine
; ********* Serial Receive Interrupt *********
btfsc PIR1,5 ; check if serial receive interrupt is set
call _ReceiveSerialData ; call receive serial data subroutine
; ********* Serial Transmit Interrupt *********
btfss _TxFlag ; check if serial transmit flag is set
goto InterruptHandlerEnd ; goto interrupt handler end
btfsc PIR1,4 ; check if serial transmit interrupt is set
call _TransmitSerialData ; call transmit serial data subroutine
InterruptHandlerEnd
retfie FAST ; return from the interrupt
ENDASM

My question is, do I need to have my wsave, ssave and psave variables for context saving or does the 18F2480 handle all the context saving and restoring? If I do need context saving, what variables do I need?


Any help would be greatly appreciated.


Thanks

Richard

Kamikaze47
- 5th March 2009, 12:35
Yes you need to save the context. Look at the PIC18F2480's data sheet page 128. It even gives you the ASM code to save and restore the context.

Charles Linquis
- 5th March 2009, 13:37
Using Darrel Taylor's "Instant Interrupts" would get the job done right the first time.

Richard Storie
- 5th March 2009, 19:40
Thanks for the replies.

Richard