View previous topic :: View next topic |
Author |
Message |
ccmcca
Joined: 08 Oct 2005 Posts: 13
|
PIC TO PIC COMUNICATION |
Posted: Sat Oct 29, 2005 1:58 pm |
|
|
How can i send a variable from one pic to another?
Is rs232 or I2C the better method?
I need an example.
Thanks!!.- |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Sat Oct 29, 2005 3:08 pm |
|
|
It depends on the length of your transmission line (in meters), on your desired data rate and directionality of your communication, your constraints such as power consumprion, board size, EMI (including galvanic isolation) and - finally - cost. Tell us more about your application.
Here are a few typical cases (in no particular order):
* A "master controller" and secondary controller(s) on the same board (or at least in the same box without a lot of EMI). I would recommend I2C. Most PICs have a hardware I2C protocol engine, plus I2C doesn't require bus transceivers. There is code for I2C master and I2C slave in this forum.
* Pier-to pier network. Take a look at Controller Area Network (CAN). Again, there is code for CAN comunication in the forum and in the examples. However, CAN requires bus transcievers. |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Sat Oct 29, 2005 3:14 pm |
|
|
kender wrote: | * Pier-to pier network |
You tie your boat to a PIER and you talk to your PEER... _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
Guest
|
|
Posted: Sat Oct 29, 2005 4:16 pm |
|
|
I have the two chips in the same board.
this is the code
receiver
#include "mainbalanza.h"
#int_RDA
RDA_isr()
{
printf(LCD_PUTC,"DEBUG";
}
void main()
{
ini();
while(1)
{
}
}
sender
#include "USvar16f627.h"
void main()
{
while(true)
{
printf("%S\n\r","16f627";
}
} |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sun Oct 30, 2005 7:49 am |
|
|
Read the CCS FAQ. It has an example and tells you what CCS example code you can use to implement the example. |
|
|
Ttelmah Guest
|
|
Posted: Sun Oct 30, 2005 7:58 am |
|
|
Also look at the threads here, about interrupts, and serial interrupts in particular.
Your receive interrupt _must_ retrieve the character, or it'll sit in a permanent loop, since it'll keep retriggering waiting for the character to be accepted. You are sending 8 characters, and never retrieving any...
Best Wishes |
|
|
|