Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Communication between two PIC advice

Status
Not open for further replies.

andi_

Newbie level 6
Joined
Aug 9, 2010
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,351
There are already tons of threads similar to this, I'm sorry for posting a new one. But what I seek is advice, should I use methods such as IC2 or I can just program my own method. What I did for my project is using programming instead of IC2, by directly connecting both PIC pins and create a simple pulse by enabling and disabling a pin, and take readings during pulse is high. My question is, is this a good practice, or should really use IC2 to connect them?

p/s: Usart is unavailabe since I use it to connect to my PC.

Example of my code
Code:
void main() {
    ...
    ...
    while (1) {

        cache = PORTB & 0x0f;

        if (RW == 0 && EN == 1 && data_in == 0) {
            /* Write */
            while (EN != 0)
                continue;
            while (data_in < 4) {
                while (EN != 1)
                    continue;
                cache |= DT << data_in;
                while (EN != 0)
                    continue;
                data_in++;
            }
            data_in = 0;
        }

        if (RW == 1 && data_in == 0) {
            /* Read */
            TRISA = TRISA_R; //set to read config
            // Generate 1 pulse
            EN = 1;
            EN = 0;
            //Start sending data
            while (data_in < 4) {
                EN = 1;
                DT = PORTB >> (4 + data_in);
                EN = 0;
                data_in++;
            }
            data_in = 0;
            TRISA = TRISA_W; //reset to write config
        }
       ...
       ...
}
 

Hi,

There is no problem in connecting two pic together like that - you are creating a simpler version of whats known as a software usart or "bit banging" thats often used when a chip does not have a hardware usart or it is already doing something else.

When linking the ports between the pics insert a 1k resistor in series to help prevent any damage if the ports are crossed over by mistake.

The problem you have is the distance / speed of signal that +5v can reliably cover, the same applies to SPI and I2C links.
A good quality shielded cable will help.
 
  • Like
Reactions: andi_

    andi_

    Points: 2
    Helpful Answer Positive Rating
Thank you very much for the advice. :D
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top