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 support@ccsinfo.com

Interrupt handling

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



Joined: 14 Aug 2009
Posts: 4
Location: India

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

Interrupt handling
PostPosted: Fri Aug 14, 2009 9:49 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Aug 14, 2009 11:14 am     Reply with quote

See this thread for a detailed explanation of the CCS interrupt handler code:
http://www.ccsinfo.com/forum/viewtopic.php?t=29173
unni.anad



Joined: 14 Aug 2009
Posts: 4
Location: India

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

PostPosted: Fri Aug 14, 2009 11:25 am     Reply with quote

Thanks for your fast and efficient reply
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