CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

using the fast interrupt option

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
valemike
Guest







using the fast interrupt option
PostPosted: Thu Oct 28, 2004 6:08 am     Reply with quote

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? Question
jventerprises



Joined: 01 Apr 2004
Posts: 43
Location: Boston

View user's profile Send private message Visit poster's website

context swap
PostPosted: Thu Oct 28, 2004 6:17 am     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

Re: using the fast interrupt option
PostPosted: Thu Oct 28, 2004 6:58 am     Reply with quote

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? Question


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

View user's profile Send private message Send e-mail

PostPosted: Thu Oct 28, 2004 7:02 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Thu Oct 28, 2004 7:55 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Oct 28, 2004 8:18 am     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Oct 28, 2004 8:32 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group