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

FullDuplexSerial.spin problems

Jared5755Jared5755 Posts: 26
edited 2008-03-04 07:46 in Propeller 1
I'm trying to make a simple "Hello World" program using a serial connection to a PC.· Nothing is being outputted to the PC.

Here's the hardware setup:
  • Propeller Proto Board
  • RS232 Level Shifter Board
  • Bray's Terminal (9600 baud, 8 data bits, no parity, 1 stop bit, no handshaking)

I know my PC's com port is working because I tested it using another device.· I've also tried all the different values for "mode" in the fullduplexserial command.· Also, I've tried baud=9600, but nothing works.

Thanks for any help.

CON
  rxpin=6
  txpin=7
  mode=3
  baudrate=-9600

OBJ
  serial        : "FullDuplexSerial"

PUB Main 
  serial.start(rxpin, txpin, mode, baudrate)
  repeat
    serial.str(string(" Hello World"))
    waitcnt(3_000_000 + cnt)

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2008-03-02 01:11
    Hmmm, if this IS your program then you are missing this:
      _CLKMODE = XTAL1 + PLL16X
      _XINFREQ = 5_000_000
    
    
    



    By default the prop runs off it's internal RCFAST oscillator at 12Mhz or so.
    The poor serial object needs to know the clock frequency to set the baud rate and it hasn't been told.

    I made a similar mistake very early on in my prop programming. smilewinkgrin.gif

    *Peter*
  • Luis DigitalLuis Digital Posts: 371
    edited 2008-03-02 01:32
    I found in my HD this code of test for several things:
    {{ General.spin }}
    
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
    Obj
     
      Serial : "FullDuplexSerial"
      txt: "TV_Text"
      sim: "Simple_Numbers"
    
    PUB Main| data, d
      txt.start(12)
      txt.str(string("Listos: "))
    
      dira[noparse][[/noparse]16]~~
    
      !outa[noparse][[/noparse]16]
    
    '  Serial.Start(31,30,%0101,9600)
      Serial.Start(31,30,%0100,9600)
    
      Serial.str(string("HOLA!"))
      Serial.rxflush
    
      repeat until data == "1"
        data := Serial.rx
        txt.dec(data)
        txt.str(string(" - "))
        txt.str(@data)
        !outa[noparse][[/noparse]16]
    
      waitcnt(clkfreq + cnt)
    
      Serial.Stop
    
      !outa[noparse][[/noparse]16] 
    
      repeat
    
    



    Keep in mind rxpin and txpin.

    I expect that serve you.

    Hello to everyone again. wink.gif
  • Jared5755Jared5755 Posts: 26
    edited 2008-03-02 03:04
    Thanks a lot guys.· It's working now.· One thing seems strange though, it doesn't work unless I use mode=4.· Now, according to the documentation, there is no 4

    _______________________________________________
    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
    
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-02 03:19
    Mode 4 is %0100. So bit 2 is set which is open-source tx. smile.gif
  • Jared5755Jared5755 Posts: 26
    edited 2008-03-02 04:25
    Oooh, I didn't pick that part up apparently. Thanks
  • deSilvadeSilva Posts: 2,967
    edited 2008-03-02 11:41
    Just some corrections:

    The main issues in the OP's program seemed to be mode = 3 and baud = -9600.

    Peter is right, that you need a crystal setting to be able to sync. RCFAST however is fine for other situations and CLKFREQ is set to 12_000_000 implicitely. However this it not exact! You would generally see some characters transferred , but some will be garbled.

    There is no explanation that the OP's program only works with mode=4. This would need a pullup at the transmission line, which would be overridden by driving the line @3volts. But the hardware at the transmit line can be more complex of course...
  • william chanwilliam chan Posts: 1,326
    edited 2008-03-04 01:11
    Anybody knows what's the txpin and rxpin for PropRPM?

    Which mode should I use for PropRPM?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.fd.com.my
    www.mercedes.com.my

    Post Edited (william chan) : 3/4/2008 1:23:17 AM GMT
  • william chanwilliam chan Posts: 1,326
    edited 2008-03-04 07:36
    Nevermind. I found it to be pin 30 and 31.

    I also have the same problem with the PropRPM board, ie. only setting the mode to 4 can bi-directional communication with the PC work.

    If I set it to mode 1, only data from Prop to PC works, data from PC to Prop does not get through.

    Why is that?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.fd.com.my
    www.mercedes.com.my
  • Harrison.Harrison. Posts: 484
    edited 2008-03-04 07:46
    The mode parameter is defined as a series of bits. So what you would do is specify your mode as a binary number for easy reading: %0100 in your case.

    I would recommend you try 0 (%0000) for your mode. This should work for the majority of setups that use a rs232 shifter or ftdi chip.
Sign In or Register to comment.