Communication between two PicChip


Closed Thread
Results 1 to 29 of 29

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Communication between two PicChip

    That is why you need to use the hardware serial port! If you use SERINx you have to sit and wait for the first transition of the start bit of the first char to come in. If you use HSERIN instead, you could simply test for PIR1.5 (at least that is what it is in the 18Fs). It gets set AFTER the whole byte is received, so in just a few instructions, you can tell if the first byte came in. If that bit isn't set, move on. If it is set, then you know there is a char in the receive buffer, so then you can issue the command HSERIN [dummy]. If Dummy = $55 then you can continue to grab chars. Virtually no overhead, and as long as you give it a
    little thought, you don't even need interrupts. It will NEVER lose the first character.

    Although I always advocate using interrupts, if you didn't want to mess with them, you could:

    Figure out the loop time of your slave device. Then you could do the following:

    Main:
    GotChars = 0
    If PIR1.5 then
    Hserin [FirstByte] ;------------ You don't need a timeout here because you already know you have a char
    if FirstByte = $55 then
    HSERIN 50,NotValid, [STR receivebuffer \numbytes]
    GotChars = 1
    endif
    endif
    NotValid:
    ....rest of program here....

    goto main

    ;------------------------------------------------------------------------------------
    And your master -

    .....

    HSEROUT [$55]

    pause (this should equal the length of the slave's program loop + a few mSec)

    HSEROUT [whatever you want to send]

    .......
    Charles Linquist

  2. #2
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: Communication between two PicChip

    i know what you mean. but why did it work before and now it does not.... i can see from my scope the the same signal is going in the pic.. why the heck doesn't it read it.

    K

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Communication between two PicChip

    Maybe you should try smaller-value pull-up resistors. Although most I2C devices can't sink much current, a PIC can sink 25mA easily. You could use 560 ohm pull-up resistors on each end if you had an extremely noisy environment or long wires.

    Also, if your two devices aren't on the same PCB, could there be a difference in GND potential between the two devices?
    Charles Linquist

  4. #4
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: Communication between two PicChip

    and i do have a I have the two breadboards sitting side by side, so maybe 9inch of wire between the two. I added 560ohmpull up resistors but nothing changed from before. and I do have a ground wire between them ..
    Last edited by lerameur; - 14th November 2011 at 05:40.

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: Communication between two PicChip

    WHAT is the best technique to communicatebetween two Pic Chip ??
    I2C ? HSEROUT ? .....

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Communication between two PicChip

    There are so many answers to that question. "Best" is a big word.

    While there are lots of options, just quit fighting and use HSEROUT/HSERIN. Easy to use, and has full PBP and DT-INT support. It is a waste of my time to try to convince you of anything. If you choose to use that method I propose, I will give you some pointers, if you don't, you will have to look for help from others.
    Charles Linquist

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: Communication between two PicChip

    I was heading in that direction using HSEROUT, starting reading the pic datasheet communication section and that led me to ask that question. I'll be working on HSEROUT tonight. I think it is a better practice then using serout in a free style way.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts