Shop OBEX P1 Docs P2 Docs Learn Events
FullDuplexSerial communication problems — Parallax Forums

FullDuplexSerial communication problems

mlantingmlanting Posts: 2
edited 2011-02-21 16:03 in Propeller 1
Hello,
I am trying to get a propeller to send information to my computer using the FullDuplexSerial object. I created a simple test program just to see if I could send a word and receive it using the Python pySerial module. My Spin code is just:
OBJ

  serial        :               "FullDuplexSerial"

PUB Main

  serial.Start(31, 30, 0, 9600)
  repeat
    serial.str(string("test"))
    waitcnt(clkfreq + cnt)

When using the python library, I am receiving bytes where the second nibble is correct, but the first one is not. For the string test, I should receive the bytes:

0x74 0x65 0x73 0x74

However, if I set the serial port settings to 8 data bits, 1 stop bit, and no parity, I receive:

0xb4 0xb5 0xb3 0xb4

I get the same results using other terminals, including the parallax serial terminal. Does anyone have an idea as to what the problem might be?

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-21 12:56
    You don't switch to chrystal? (You remember ... the clock settings in CON ). Then the internal clock might be to slow to do 9600 baud.
  • RockyDRockyD Posts: 17
    edited 2011-02-21 13:09
    I have found in order to do serial communication you need a clock calibrated more accurately than what the internal oscillator is. You need to use an external crystal.

    One thing that you can do though for testing purposes is to adjust the baud in the prop code but still use 9600 on the PC side. So you could try 8800 or 10300 or other numbers 10 - 30 % off. I have found the internal oscillator to be off by 10% - 30%. Note, anything off by more that 10% by definition will not work for serial because they share clocks and there is 10 bits communicated in a serial transitional.

    Rocky
  • mlantingmlanting Posts: 2
    edited 2011-02-21 16:03
    Using the external crystal fixed it. Thanks.
Sign In or Register to comment.