|
|
View previous topic :: View next topic |
Author |
Message |
c0de
Joined: 14 May 2007 Posts: 14
|
rs232 with pic16f876 |
Posted: Mon May 14, 2007 3:50 am |
|
|
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
|
|
Posted: Mon May 14, 2007 4:37 am |
|
|
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 |
|
|
|
|
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
|