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

rs232 with pic16f876

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



Joined: 14 May 2007
Posts: 14

View user's profile Send private message

rs232 with pic16f876
PostPosted: Mon May 14, 2007 3:50 am     Reply with quote

Hello.
I'm trying to make a program for a pic16f876 connected via rs232 with a Gumstix microcomputer. The PIC mc is reading from RB0 (input pin) the data transmitted by an optical transducer and transmits any pin change to the microcomputer which counts the changes. When the counter has a certain value, the microcomputer should send a message to the PIC in order to change the state of an output pin (i.e. RA0).
Question: is it possible to receive strings while sending other strings? (without affecting the send)... For example like in Ansi C for sockets:
while(1)
if(somevar = recv(...) { read the input buffer }
else { continue sending strings }

Thanks
Ttelmah
Guest







PostPosted: Mon May 14, 2007 4:37 am     Reply with quote

You need to use the hardware UART for the transmit and receive, with 'interrupt driven' drivers for both directions. There is an example for the 'receive' direction, in EX_SISR.C, and one for the 'transmit' direction, in EX_STISR.C.
Using these two sets of code together, you send characters to 'bputc', check if any data has been received, with bkbhit, and read the characters with bgetc. Within the limits of how large you make the buffers, you can send and receive, while the processor is also doing other work, and without the two operations interfering with each other.

Best Wishes
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