View previous topic :: View next topic |
Author |
Message |
valemike Guest
|
using the fast interrupt option |
Posted: Thu Oct 28, 2004 6:08 am |
|
|
I recently found that my TMR1 interrupt may hit while my RB0 interrupt is being serviced. In a nutshell, this is screwing up my PID routine.
I figure that if I can service the TMR1 interrupt while in the RB0 interrupt without leaving the ISR, the best method is to use the #fast_int directive.
I realize that I will have to save registers myself; does this mean then that I have to save the "STATUS", "W_REG", "OPTION" reg myself too, just like the PIC manual shows? |
|
|
jventerprises
Joined: 01 Apr 2004 Posts: 43 Location: Boston
|
context swap |
Posted: Thu Oct 28, 2004 6:17 am |
|
|
yes it does. pay special attention to the bank and page info as well... _________________ Jon |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
Re: using the fast interrupt option |
Posted: Thu Oct 28, 2004 6:58 am |
|
|
valemike wrote: | does this mean then that I have to save the "STATUS", "W_REG", "OPTION" reg myself too, just like the PIC manual shows? |
No it does not. The PIC18F hardware based high priority interrupt can use the fast return stack which automatically save the BSR, WREG and Status registers. These are automatically restored on exit with the RETFIE 1 (fast return from interrupt) instruction. Some versions of the CCS compiler incorrectly do a normal return from interrupt instead of a fast return so to handle this you can add your own fast return instruction at the end of your handler.
Andrew |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Oct 28, 2004 7:02 am |
|
|
Where did you get you information. The PIC18 high priority are put on the fast return stack. Also, there is no option register for the PIC18. Are you using a pic18 or pic16? The pic16 does not have a fast isr. |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Thu Oct 28, 2004 7:55 am |
|
|
asmallri,....
Do you have a sample snipit of how to do this?
Is it a #asm instruction that you put at the end of the
#int (interupt service routine) |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Oct 28, 2004 8:18 am |
|
|
Read the PIC data sheet. The 'RETFIE' has a parameter. 0 for normal and 1 to restore the shadow registers (BSR,Wreg,Status) |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Thu Oct 28, 2004 8:32 am |
|
|
treitmey wrote: | asmallri,....
Do you have a sample snipit of how to do this?
Is it a #asm instruction that you put at the end of the
#int (interupt service routine) |
A more complex response than you asked for. This is because the handler deals with multiple high priority interrupt sources....
Code: | /* Map the high priority interrupt vector */
#org 0x0008, 0x000f
void my_hp_intr (void)
{
#asm
goto 0x0100
#endasm
}
/* Map the low priority interrupt vector */
#org 0x0018, 0x001f
void my_lp_intr (void)
{
#asm
goto 0x0200
#endasm
}
#org 0x0100, 0x01ff
void HPIntrHdlr(void) {
/**************************************************************************
; HPIntrHdlr - High Priority Interrupt Service Routine
;
// other stuff removed
#asm ASIS
retfie 1 //; return from interrupt
//; *** END OF CRITICAL CODE TIMING for Console TX pin output
//; End of High Priority Interrrupt Handler
#endasm
}
|
Andrew |
|
|
|