Shop OBEX P1 Docs P2 Docs Learn Events
Receiving Serial — Parallax Forums

Receiving Serial

heathclfheathclf Posts: 43
edited 2008-08-15 21:57 in Propeller 1
Hello all,

I've posted before, but am still very new to microcontrollers. I'm trying to receive string / numbers / whatever from my pc to my propeller chip. I'm using FullDuplexSerial, just because, but can't get it to work.

My code is really just:

Debug.rx
Debug.str(string(rxbyte))

Where:

OBJ

Debug: "FullDuplexSerial"

and

PUB rx : rxbyte

'' Receive byte (may wait for byte)
'' returns $00..$FF

repeat while (rxbyte := rxcheck) < 0

I keep getting errors. Any help would be much appreciated. When replying, please don't assume I know too much.

Thanks.

Comments

  • tpw_mantpw_man Posts: 276
    edited 2008-08-13 01:24
    You cannot declare a string's contents when the Propeller is running. When the code is compiled and downloaded to the Propeller chip, the compiler puts the text into memory. You can do this: 'debug.tx(debug.rx)' That will echo any character that the Propeller receives.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1011, so be surprised!


    Advertisement sponsored by dfletch:
    Come and join us on the Propeller IRC channel for fast and easy help!
    Channel: #propeller
    Server: irc.freenode.net or freenode.net
    If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
    tongue.gif
  • heathclfheathclf Posts: 43
    edited 2008-08-15 21:53
    Checked more documentation, and figured it out. Problem solved, but I do have another that is pretty annoying. In order to communicate with my computer, the serial lines from my Propeller chip uses reversed logic, whereas my RS232 uses normal logic. I have to take the logic through an inverter, which seems silly to me. There are modes, in the library FullDuplexSerialPlus, which can be supposedly changed, but it doesn't seem to. I put a scope on my output, and get the identical signal, which won't communicate with my computer. As soon as I take it through an Inverter, it works just fine.

    Here's some source code from the library:

    PUB start(rxpin, txpin, mode, baudrate) : okay

    '' Start serial driver - starts a cog
    '' returns false if no cog available
    ''
    '' mode bit 0 = invert rx
    '' mode bit 1 = invert tx
    '' mode bit 2 = open-drain/source tx
    '' mode bit 3 = ignore tx echo on rx

    stop
    longfill(@rx_head, 0, 4)
    longmove(@rx_pin, @rxpin, 3)
    bit_ticks := clkfreq / baudrate
    buffer_ptr := @rx_buffer
    okay := cog := cognew(@entry, @rx_head) + 1

    using a 1 or a 0 doesn't seem to invert the output. How can I accomplish this?

    Thanks a lot.
  • Erik FriesenErik Friesen Posts: 1,071
    edited 2008-08-15 21:57
    A 1 is 1 in binary. How about trying a %11, or 3? which would invert rx and tx
Sign In or Register to comment.