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

getc() in main with ISR

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



Joined: 27 Jul 2013
Posts: 79

View user's profile Send private message

getc() in main with ISR
PostPosted: Sat Feb 08, 2014 1:22 am     Reply with quote

How does the compiler handle getC() in the main() with ISR written.
My pic has two sensors attached to it on ONE the serial port, one runs on interrupts and other has to be polled and returns exactly X bytes of data.
I am thinking of writing ISR for interrupt based sensor, and polling the data in main for poll based sensor.
Is there a better way of doing this?
Does getC() get the character from hardware buffer incase of hardware UART?
Does the program still enter ISR if getC() is used?
Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Sat Feb 08, 2014 1:48 am     Reply with quote

No, and yes.....

INT_RDA will pre-empt anything using getc, in the main. getc will never receive a character while the interrupt is enabled.

Just disable the interrupt, for the code section where you want 'polling' action, and then getc in the main will work.

However I have to say consider 'rethinking' your approach, and using a single interrupt writing to a circular buffer.
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