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

return to start of main() from ISR

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



Joined: 08 Sep 2008
Posts: 17

View user's profile Send private message

return to start of main() from ISR
PostPosted: Mon Aug 30, 2010 5:01 pm     Reply with quote

Hello Guys

I would like to know is it possible to return from interrupt routine directly to the head of the main() function (not to the place where the interrupt occurred).

For example I wrote a program to read from three different sensors:
Code:

#INT_TIMER0
 void  TIMER0_isr(void)  // interrupt every 1 second 
{
 if(flow >=2)
        {
           flow = 0 ;
          s1=0;
          s2=0;
          s3=0
        }
        else flow ++;

}

void sensor1();
void sensor2();
void sensor3();

main()
{

 if(flow == 0 && R==0)
   {
   R =1 ;
sensor1();  // .5 second required for the reading
}

if(flow == 1 && C==0)
   {
   C =1 ;
sensor2();// .5 second required for the reading
}

if(flow == 2 && A==0)
   {
   A =1 ;
sensor3();// .5 second required for the reading
}

}

Well this is not multi-tasking nor threading or what so ever.

I just want to make sure if any one of my sensors is tripping the rest will continue working.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 30, 2010 7:19 pm     Reply with quote

To narrowly answer your question, without looking at program design
issues, see this thread on the reset_cpu() function.
http://www.ccsinfo.com/forum/viewtopic.php?t=18165
jventerprises



Joined: 01 Apr 2004
Posts: 43
Location: Boston

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

jump to main
PostPosted: Tue Aug 31, 2010 9:09 am     Reply with quote

well, i'm not sure this is a supported function, and the manual clearly says pointers to functions are not allowed...... but.....

i have done this in the past on 18F series parts and it works.

int32 *main_ptr;
main_ptr = &main;
goto_address(main_ptr);

this jumps to main.

a cleaner way is to just reset the cpu with a reset_cpu();
_________________
Jon
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