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

Unable to call function in interrupt

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



Joined: 05 Feb 2016
Posts: 1

View user's profile Send private message

Unable to call function in interrupt
PostPosted: Wed Feb 24, 2016 1:12 am     Reply with quote

Hello everyone
I am writing a code in pic16f877a using Timer1 interrupt. While defining the interrupt above main, i called a function in it. But on compilation it is showing error. I'm new to interrupt part of programming. Need the help badly.
Code:

#int_TIMER1
void  TIMER1_isr(void)
{
 int i=0;
 //value=get_timer1;
     i++
     if(i==6000)
      {
        i=0;
       
        bty_voltage_sensing();
        goto lable4;
        //output stop
      }
     
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Wed Feb 24, 2016 1:42 am     Reply with quote

Nothing to do with the interrupt. Just general C. A function _or it's prototype_, must be defined before you can call it. You need to add a function prototype for the code you want to call, before you define the interrupt function.

General comments. Where on earth is the label you are trying to goto?. If this is somewhere else in the code, then you will almost certainly result in a stack imbalance. Result code crashing....

However the code is not going to work, for several more reasons. an int in CCS, is an 8 bit integer. Can this ever get to 6000?. Then you are setting i to zero every time the interrupt is called, so again it is never going to get to 6000....

Rethink how this is done. You need to declare i as a static int16 (which will then only be initialised once, and can count to 6000). Then have the code just set a flag to say that the sensing is required, and do the sensing in your main code.
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