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

Communication between 2 microcontrollers

 
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

Communication between 2 microcontrollers
PostPosted: Wed Nov 21, 2007 7:03 am     Reply with quote

Is it possible to control 2 serial lines with a pic16f876? (one serial for PC and one serial for another pic16f876) ... or in other words, to have multiple Rx/Tx pins.

I would like to have something like this:


PIC1 <----Rx/Tx----> PIC2 <----Rx/Tx----> Computer

I wonder if it's possible to have for PIC2, two rs232 line... like:
#use rs232(baud=9600, bits=8, parity=N, xmit=PIN_C6, rcv=PIN_C7,stream=Computer)
#use rs232(baud=9600, bits=8, parity=N, xmit=PIN_B1, rcv=PIN_B2, stream=PIC1)

... and control the PC and PIC1 streams.

P.S: if it's possible, do I need something (like max232) between the RX/Tx lines of the two PICs or is enough to connect PIC1(Tx) - PIC2(Rx), PIC1(Rx)-PIC2(Tx) directly.

Thank you.
Ttelmah
Guest







PostPosted: Wed Nov 21, 2007 7:50 am     Reply with quote

Yes, you can control two serial lines. The 'second' serial (not using the hardware pins), will be implemented as a 'software' serial link.
Problems of this, are that there is no buffering in either direction, so a chip 'receiving' on such a link, _must_ poll the receive line (kbhit), at least once every half bit time, to have any hope of spotting a character arriving, and that communications in both directions, can/will be damaged, if the processor is asked to do anything else (service interrupts...), while the data is being sent/received.
In general, if one chip is talking to the PC using it's hardware UART, and then acts a 'master' device, talking to the other PIC, and initiating all transfers, with the second PIC, using it's hardware port, this can be made to work.
No, you don't need MAX232 type buffers, provided the connection is reasonably short.
Worth asking though, if you could use the second hardware serial that is present?. As well as the normal asynch serial, there is a synchronous interface, that handles SPI, and I2C connections, and this has full buffering and hardware present, to do the transfers. Much faster, and more reliable than software asynch, if the hardware is not being used for anything else...

Best Wishes
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed Nov 21, 2007 9:57 am     Reply with quote

Microchip does make several PIC's that have two UARTs. Take a look and see if one of these might meet your requirements.
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