View previous topic :: View next topic |
Author |
Message |
unni.anad
Joined: 14 Aug 2009 Posts: 4 Location: India
|
Interrupt handling |
Posted: Fri Aug 14, 2009 9:49 am |
|
|
Whether ccs compiler itself take care of saving the W-REG and STATUS reg during when it serves an interrupt routine. In an example code provided it is shown as to be done by the programmer. (given in ALP).
Code: |
#asm
//store current state of processor
MOVWF save_w
SWAPF status,W
BCF status,5
BCF status,6
MOVWF save_status
// Save anything else your code may change
// You need to do something with PCLATH if you have GOTOs
// remember to check to see what interrupt fired if using more than one!!
// code for isr
BCF t0if
INCF counter,F
BTFSC zero_flag
INCF (&counter+1),F
// restore processor and return from interrupt
SWAPF save_status,W
MOVWF status
SWAPF save_w,F
SWAPF save_w,W
#endasm |
In an another example using C
Code: |
#INT_TIMER2 //HIGH
void timer2_isr()
{
count++;
} |
What is the difference ? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
unni.anad
Joined: 14 Aug 2009 Posts: 4 Location: India
|
|
Posted: Fri Aug 14, 2009 11:25 am |
|
|
Thanks for your fast and efficient reply |
|
|
|