PDA

View Full Version : pic to pic communication pic2pic



aftab
- 14th August 2007, 11:11
Hello,

What is the easiest way to communicate between two pics ?
I want to send data from pic12c672 to pic16f84a using minimum number of pins.
The data format will be numbers (I am yet to solve my earlier problem of A/D conversion)

Some examples would be helpful.

Thanks
Aftab

----------------------
pic to pic communication pic2pic join two pic serout serin

mackrackit
- 14th August 2007, 11:26
Use SERIN/SEROUT or SERIN2/SEROUT2. One wire is all you will need.

aftab
- 15th August 2007, 00:36
http://www.tigoe.net/pcomp/pic/pic-serial-pbpro.shtml

Trying to understand.

mackrackit
- 15th August 2007, 02:25
That looks a lot like the manual.

There are a couple of things to keep in mind:

The internal oscillator if your chip has one will not be good enough.
Baud and parity has to be the same on both ends.
include "modedefs.bas" needs to be at the beginning of the program.

The manual has enough examples to get started. If you run into a particular problem let us know.

The code will look some thing like this.


SEROUT PORTC.4,T2400,[9,DEC 10] ' Sends at 2400 baud TRUE,the character 9and the decimal 10
SERIN PORTC.4,T2400,[9],net 'Waits for the character 9 and writes the next value to the variable net.

flipper_md
- 6th October 2007, 16:48
Hello

I've got two 16F628A to communicate with SERIN/SEROUT at 2400baud, on 2 wires, and it manage to work. 2400bauds seems to be a safe speed.
Lots of sync error since my program is doing stuff and is not always waiting for data, but it will respond in less than 2-3 sec at worst case.

I'm curious about how you would make it work with only 1-wire(for 2 way comm)!? Or is it for 1 way comm only?
How the port would be set, does it have to be swtiched live from input to output?


Also, I wanted to know if there's a way to get the PIC going if no wire is connected, as currently it hang the program as soon as it hit SERIN.(even timeout is not triggered).
Can this be fix by adding resistor or caps between TX and RX?

Maybe onewire comm will get this

mister_e
- 6th October 2007, 16:58
The much reliable solution for me would be to choose a PIC with a Built-in USART(like yours) and use interrupt instead of any bit banging solution as SERIN.

flipper_md
- 8th October 2007, 17:16
Thanks Steve

I'll look into that one day.

Soo many PIC are availables, with so many features! :)

edit:
woohoo!! just realised what Usart could do!! =)