Shop OBEX P1 Docs P2 Docs Learn Events
Serial Interconnect between two Propellers — Parallax Forums

Serial Interconnect between two Propellers

fbeekfbeek Posts: 14
edited 2010-08-26 10:14 in Propeller 1
Hello,

i want to connect two propeller chips together over a serial link.

I tried this with the PCFULLDUPLEX serial object and that works gread at 115200 Baud in mode 0.

But there is one thing that i can't understand. When i read a byte with .rxcheck and put this out to my PC over second link i get always 255 out if there is nothing transmitted
repeat
    intercom:=uart[1].rxcheck
    if(intercom > -1)
    uart[0].tx(intercom)

I can filter that with
repeat
    intercom:=uart[1].rxcheck
    if(intercom > -1 AND intercom < 255)
    uart[0].tx(intercom)

But i think this is not the best way.

Can someone give me some help for this Problem.

fbeek

Comments

  • Luis DigitalLuis Digital Posts: 371
    edited 2010-08-24 11:42
    Hello,

    You have a problem in your program:
    repeat
        intercom:=uart[1].rxcheck
        if(intercom > -1)
          uart[0].tx(intercom) 'Missing space, Tab
    
  • Duane DegnDuane Degn Posts: 10,588
    edited 2010-08-24 11:43
    I've had similar problems before. I think a pull-up resistor solved the problem for me. If a pull-up doesn't work, try a pull-down.

    Duane
  • BTXBTX Posts: 674
    edited 2010-08-24 18:05
    fbeek, is this usefull for you ?
    repeat
        intercom:=uart[1].rx
        uart[0].tx(intercom)
    
  • fbeekfbeek Posts: 14
    edited 2010-08-25 07:29
    Hello,

    thank you for your replies.

    @Luis Digital: Thats a C&P Error.Sorry

    @BTX: I will try it later but ich think thats not a nice way because the Programm hangs at this point. With rxcheck that can't happen.

    Could it be that i must invert the tx signal?
  • BTXBTX Posts: 674
    edited 2010-08-25 07:57
    I suppose if you invert the signal you'll get 0 instead 255, same problem inverted.
    Use your code, don't worried to compare "if(intercom > -1 AND intercom < 255)", that sounds good for me, although talking about best programming technics, I'm not the best to answer you.
  • kwinnkwinn Posts: 8,697
    edited 2010-08-25 08:13
    fbeek, I beleive your problem is indentation. "uart[0]..." line will always be executed if not properly indented. 255 is decimal representation of -1. Try indenting the line.
  • mparkmpark Posts: 1,305
    edited 2010-08-25 09:00
    What size is "intercom": byte, word, long?
  • fbeekfbeek Posts: 14
    edited 2010-08-25 09:32
    I found the problem. MPARK gave me the idea to look at the sizes.I changed it to long and now it works. Can you explain that for me? I thought the UART transmits byte/char values.
  • mparkmpark Posts: 1,305
    edited 2010-08-25 10:46
    The rxcheck method returns -1 ($ffffffff) to signify no character. Storing -1 into a byte variable truncates it to the lowest 8 bits ($ff). Spin byte variables are unsigned, so byte-sized intercom ($ff) is not the same thing as -1. You could sign-extend it with ~ but then you would be unable to distinguish a valid byte of $ff from -1.
  • fbeekfbeek Posts: 14
    edited 2010-08-26 10:14
    Ahhhh....

    Thank you now i understand the whole story.
Sign In or Register to comment.