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

Aborting function when RS232 data received

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







Aborting function when RS232 data received
PostPosted: Wed Aug 30, 2006 3:20 am     Reply with quote

Hello,

I have a number of complex functions which need to run as fast as possible. However, on receipt of an RS232 character, the function need to be aborted.
Now, what I am looking for are suggestions on the best way to do this without imposing any extra burden on the functions. Is it possible? I am using the PIC18F452 chip.

Thanks.
libor



Joined: 14 Dec 2004
Posts: 288
Location: Hungary

View user's profile Send private message

PostPosted: Wed Aug 30, 2006 4:10 am     Reply with quote

This is exactly what interrupts are invented for.
nazoa
Guest







PostPosted: Wed Aug 30, 2006 4:36 am     Reply with quote

Thanks Libor, yes, the problem is how to abort the current function. NOT how to service the interrupt. It would help if you can tell me how to write an interrupt service routine that will abort the current function. Thanks.
libor



Joined: 14 Dec 2004
Posts: 288
Location: Hungary

View user's profile Send private message

PostPosted: Wed Aug 30, 2006 4:53 am     Reply with quote

Every interrupt (if enabled) aborts the running code. Search for '#INT_RDA' on this forum or in the samples. You'll find many RS232 service routines implemented using interrupts.
nazoa
Guest







PostPosted: Wed Aug 30, 2006 5:42 am     Reply with quote

Hmm, I think I am not making myself too clear here..

I am not interested in how to service the interrupt. What I want is for the function to be ABORTED. You can think of it as wanting to put a jump to the end of the function when the interrupt occurs.

The problem with an interrupt is that when the interrupt is serviced, execution resumes at the point when the interrupt occurred. This is NOT what I need.
libor



Joined: 14 Dec 2004
Posts: 288
Location: Hungary

View user's profile Send private message

PostPosted: Wed Aug 30, 2006 5:55 am     Reply with quote

OK. now I got it. sorry.

Two ideas:
the conservative way: you set a flag in the interrupt service routine and periodically check it in your code, and act upon it.

the other one: you can modify the return program counter value stored in the return stack (it is software addressable in the new PICs), so the program execution after exiting the interrupt servicing will not continue where it left in the main code, but can jump to any place in the code. Need very careful programming.
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