Shop OBEX P1 Docs P2 Docs Learn Events
Trouble with serial comms via Propeller Plug — Parallax Forums

Trouble with serial comms via Propeller Plug

telluriantellurian Posts: 52
edited 2007-04-22 06:55 in Propeller 1
I am having trouble communicating with my PC using the Propeller Plug and the default pins 31 and 30 for RX and TX respectively. I can download and run programs fine, but when I use the FullDuplexSerial object to do serial comms with my PC I cannot recieve characters (properly) or send them

This is my first go at the Propeller ... so I may be a bit obtuse (!) Can't I use the Propeller Plug to talk to the PC after downloading a program? I'm using the Propeller Education Kit wired as per the instructions and can run programs successfully ... but communication back to the PC isn't happening. It is not the DTR reset problem, that happens only when I disconnect the serial port, while connected I only read 0x00 even though I am sending 0x41 (i.e. 65).

I have pared the issue down to the following test code ...

con
_clkfreq = 5_000_000
_CLKMODE = xtal1 + pll16x

OBJ
RS232 : "FullDuplexSerial" 'include serial io handler

var
byte tmp

pub main
RS232.start( 31, 30, 0, 9600 )

repeat
RS232.tx( 65 )
waitcnt(40_000_000 + cnt)


Thanks, I appreciate any help!

Comments

  • CJCJ Posts: 470
    edited 2007-04-21 18:26
    is your code indented under the repeat?, that would cause this issue,

    what program are you using on the computer for the terminal? I recommend the basic stamp tool debug window

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Parallax Forums - If you're ready to learn, we're ready to help.
  • telluriantellurian Posts: 52
    edited 2007-04-21 18:28
    yes, it is indented properly ... the form editor seems to have stripped away the leading spaces.

    thanks
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-21 19:31
    1) The form editor does strip away leading spaces unless you use "code" and "/code" in square brackets around the section involved.

    2) Your code looks correct. Have you tried a simple serial terminal program like Hyperterm? I've done this sort of thing exactly as you've posted and it's worked fine for me. I have a Macbook, but it runs Windows XP Home Edition and the Propeller Tool just fine with a PropPlug and (Bleackh!) HyperTerm.
  • telluriantellurian Posts: 52
    edited 2007-04-22 04:10
    Thanks Mike.

    1) Thanks for the code /code tip.

    2) I tried Hyperterm and Realterm, neither work. I reinstalled the USB drivers too ... nothing.

    I am an old programmer hack (professional, programming micro's since the 6502 ... anyone remember those?) familiar with a variety of languages (mostly C/C++, recently a PIC and Zilog fan) so my problem isn't simply 'new-be' befuddlement (but I can be dumb sometimes). I am glad to hear that you can use the PropPlug, it seems obvious to me that it should work, but it does not.

    I can download the code into RAM and execute it successfully (the program has does a variety of things, including output to an I2C LCD which I can read OK), I am actually working on an interface for the Nordic nRF2401 2.4 GHz tranceiver and I want serial IO for debugging. HOWEVER ... serial IO back through the PropPlug just plain does not work! I can see the PropPlug tx LED flash when a character is output but I get either nothing or an 0x00 on the terminal. When I use mode 0 or the Serial.start() method I can see the TX LED flash each time a character it attempted to be transmitted. When I open the com port with either terminal program the program in the Prop stops transmitting, thus nothing in HyperTerm. If I change the mode to toggle the TX line and try with that, Hyper term open does not freeze the Prop, but the character received is 0x00, not 0x41 as expected.

    The test program is trivial and I fully expect it to work, however I wonder if there is some USB problem that I am running into. This ~should~ work ... but it does not.

    arghh, ... still stuck, any suggestions would help (even dumb thinks like 'did you turn on the power'?)

    thanks again,
    Allen
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-22 04:29
    Just like with the Stamps, the Propeller will reset when you open the serial port (you did mention that it does so when you disconnect it).

    Since you can download programs to the Propeller, the USB connection should be working since it has to work (and work well) to download.

    Do try the Stamp Editor debug window. You can download it (the Stamp Editor) from the Download section of the Parallax website.
  • telluriantellurian Posts: 52
    edited 2007-04-22 04:55
    Same thing happens with the Stamp Editor debug window (just downloaded it).

    Actually the propeller does not reset when I open the comm port, it resets when I close it. When I open the com port the PropPlug seems to freeze but the program in the propeller keeps running. I know this because other functions keep on running, specifically I can see a heartbeat LED that I set up still flash ... it is actually in the simple repeat loop along with the tx method so I know it is still executing the loop just nothing is getting out the PropPlug. When I close the port the Propeller resets.

    Arghh ... !! I don't get it.

    Allen
  • telluriantellurian Posts: 52
    edited 2007-04-22 06:55
    OK solved.

    I had to bring out the scope to look at what the Propeller was outputting ... it wasn't the right baud rate (not by a long shot!). So that got me looking at my clocking specifications.

    I used:

    _clkfreq = 5_000_000
    _clkmode = xtal1 + pll16x

    ... WRONG! It should be

    _xinfreq = 5_000_000
    _clkmode = xtal1 + pll16x

    The propeller manual p.133 explains this. If you are not using the PLL _clkfreq and _xinfreq can be used interchangeably the compiler will calculate the other value. However if the PLL is used this is not true. In that case if you use _clkfreq it will assume the crystal is 1/PLLx of that. In my case I used pll16x, so it calculated _xinfreq as 5_000_000 / 16 = 312500Hz !! Thus the baud rate was calculated wrong ..., namely being about 16x too fast (which is what I saw on the scope)!

    Classic RTFM ...

    cheers,
    Allen
Sign In or Register to comment.