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 a value from interrupt

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







return a value from interrupt
PostPosted: Sat Nov 24, 2001 6:31 pm     Reply with quote

Will a return value from a function within an interrupt get back to main or a main function? For example a keypad entry which gets polled using #int_rtcc every 20ms. When set_time() fuction is running in main, it will wait for a key to be passed to it. I know there are other ways to do this. The current method I am using works, but now I need to have mutiple fuctions to use the keys in different ways. Thanks in advance for any help or ideas.
___________________________
This message was ported from CCS's old forum
Original Post ID: 1312
Curt
Guest







Re: return a value from interrupt
PostPosted: Sat Nov 24, 2001 11:39 pm     Reply with quote

No, I don't believe there is any mechanism for this, it would be basically impossible. Since an interrupt can occur at any time (thus the name ;) ) it can be called at any time, and therefore there is nowhere to return to.

The way to pass values back is through a global register. In its simplist form you would have a register and a flag. The flag will be set true and the character will be placed in the register by the ISR.

Then in your main loop, inspect this flag. If it's true, set it false and process the register as a 'return' value, remember to disable interrupts when you inspect the flag, and don't re-enable them until after you have set the flag false and copied the character! Otherwise the ISR may run and "bad things happen".

-Curt



:=Will a return value from a function within an interrupt get back to main or a main function? For example a keypad entry which gets polled using #int_rtcc every 20ms. When set_time() fuction is running in main, it will wait for a key to be passed to it. I know there are other ways to do this. The current method I am using works, but now I need to have mutiple fuctions to use the keys in different ways. Thanks in advance for any help or ideas.
___________________________
This message was ported from CCS's old forum
Original Post ID: 1313
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