PIC to PIC Serial Communication


Closed Thread
Results 1 to 5 of 5
  1. #1
    v_merino's Avatar
    v_merino Guest

    Default PIC to PIC Serial Communication

    Hey all, can someone please show me how to successfully send a byte of data from one PIC to another PIC. Im using the SERIN and SEROUT commands but it doesnt seem like I'm doing it right. I get garbage results on the other end. Thanks for your help. This is the code I'm using:

    'TX PIC:
    Include "modedefs.bas"
    pause 1000
    SEROUT 0, T2400,[%11100010]
    END

    'RX PIC:
    SERIN 3,T2400,10000,error,RX 'wait for signal for 10 seconds
    LCDout #RX
    goto finish

    error:
    LCDout $fe, 1 'clear screen
    LCDout $fe, 2 'return home
    Lcdout "Error"

    finish:
    end

  2. #2
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello V_merino

    VM>>
    'TX PIC:
    Include "modedefs.bas"
    pause 1000
    SEROUT 0, T2400,[%11100010]
    END

    'RX PIC:
    SERIN 3,T2400,10000,error,RX 'wait for signal for 10 seconds
    LCDout #RX
    goto finish

    error:
    LCDout $fe, 1 'clear screen
    LCDout $fe, 2 'return home
    Lcdout "Error"

    finish:
    end
    <<

    Make sure your RX pin is a data pin in the TRIS registser, and make sure your TX pin is a output pin in the TRIS register.
    I don't see any of this in your program.

    Then I would try for the SIMPLER SERIN and SEROUT (until you can verify your data is actually being sent in good form..
    Use
    Serin Pin, T2400, RecDataword

    Serout Pin, T2400, DataWord


    With this verified, then put your "Flags and timers on". You could have "noise" going on from improper grounding, and that will give you trash.
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  3. #3
    carl_schell's Avatar
    carl_schell Guest


    Did you find this post helpful? Yes | No

    Arrow

    v_merino -

    One clarification I thought I would add to Dwayne's post [Hope you don't mind Dwayne ]

    Remember that though you are sending Data in Binary format "[%11100010], you are receiving the data in the decimal version of 11100010, which is 226 I am sure you already knew this, but just thought I give you a reminder.

    I double checked your code between two of my development boards and it worked perfectly for me no problem. The SerIn command will automatically take care of making your pin from an input.

    One last thing you could double check is that your variable is declared properly. The reason I say this is that typically, I lable my PortC.7 pin RX, so when I popped your code into my template, i nearly forgot to change your data storage variable to a different name, (RX2).

    ie:

    RX var PortC.7 'Nickname for RS-232 RX Pin
    RX2 var byte 'Storage variable for SerIn Data

    Best Regards,

    Carl
    www.schellelectronics.com

  4. #4
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Carl,

    Carl>>One clarification I thought I would add to Dwayne's post [Hope you don't mind Dwayne ]<<

    Thanks Carl! appreciate it eee-men-slee!

    Carl>Remember that though you are sending Data in Binary format "[%11100010], you are receiving the data in the decimal version of 11100010, which is 226 I am sure you already knew this, but just thought I give you a reminder. <<

    I never bothered to look it up <g>. but 226 is a funny character that is garbage to most <g>

    Carl>>I double checked your code between two of my development boards and it worked perfectly for me no problem. The SerIn command will automatically take care of making your pin from an input.<<

    I guess I just don't trust something automatically making something a input for me <g>. It comes from the old Phillips Chips. So I assign it a input anyhow <g>.

    I am down right now for the next 2 weeks or so... been down for about 1 1/2 weeks... bought a new house... as soon as I move in, I will be up and running again.

    Thanks again for the help!

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  5. #5
    v_merino's Avatar
    v_merino Guest


    Did you find this post helpful? Yes | No

    Thumbs up Thanks guys

    Thanks for all your help guys. I got it to work. Thanks again

Similar Threads

  1. 2 PIC, serial communication
    By lightgreen in forum Serial
    Replies: 6
    Last Post: - 21st November 2009, 15:20
  2. Replies: 11
    Last Post: - 12th July 2008, 02:36
  3. PIC to PIC "wired" serial one-way communication - SERIN2/SEROUT2
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th April 2008, 20:02
  4. Replies: 5
    Last Post: - 20th March 2006, 01:34
  5. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 15:45

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