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

Question about fast interrupts and context saving

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



Joined: 11 Jan 2008
Posts: 2

View user's profile Send private message

Question about fast interrupts and context saving
PostPosted: Wed Jan 30, 2008 12:22 pm     Reply with quote

Hello,

I'm working with a PIC18F4620, and my application has a comparator interrupt with the "fast" directive to minimize the number of instructions leading up to the ISR (#int_comp fast). I'm confused about what I need to save context when "fast" is used.

From the CCS manual:
"An interrupt marked FAST is performed without saving or restoring any registers. You should do as little as possible and save any registers that need to be saved on your own. "

However, from section 10.9 of the datasheet ("Context Saving During Interrupts"):
"During interrupts, the return PC address is saved on the stack. Additionally, the WREG, STATUS and BSR registers are saved on the Fast Return Stack. If a fast return from interrupt is not used, the user may need to save the WREG, STATUS and BSR registers on entry to the Interrupt Service Routine."

Can someone clarify this for me? Does "#int_comp fast" mean that the fast return stack is used at the end of the ISR? What other registers do I have to be concerned about?

Thank you.
Ken Johnson



Joined: 23 Mar 2006
Posts: 197
Location: Lewisburg, WV

View user's profile Send private message

PostPosted: Wed Jan 30, 2008 1:29 pm     Reply with quote

What you need to save depends on what you do in your isr. Just set a bit, probably nothing.

But, look at the asm code generated by the compiler for your isr - you'll see what regs are used.

Ken
mak



Joined: 11 Jan 2008
Posts: 2

View user's profile Send private message

PostPosted: Wed Jan 30, 2008 2:45 pm     Reply with quote

Ken - thanks for your reply. What about WREG, STATUS and BSR? Are those saved and restored automatically? Do I only have to save registers that I might overwrite in my ISR?

For the sake of argument, suppose I have an ISR that does nothing. In that case, would I have to save/restore anything, or would the processor take care of all the required registers?

Thanks,
Mark
Ttelmah
Guest







PostPosted: Wed Jan 30, 2008 3:50 pm     Reply with quote

On the '18' chips, the RETFIE 1 instruction (which will automatically be used for the 'fast' handler), automatically restores the W, Status, and the BSR. Saves a lot of work!. :-)
If a high priority handler is not present, this is used for the normal interrupts, so having a high priority interrupt, automatically 'slows' the normal interrupt handlers by a few instructions. Also, beware of the caveat, that if INT0 is used, this allways becomes a high priority interrupt, if the high interrupts are enabled there is no INT0P bit...). Hence if this is in use, and you want to ue any other high priority interrupt, you _must_ add handler coe to check which interrupt has triggered......

Best Wishes
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