Shop OBEX P1 Docs P2 Docs Learn Events
Help Please Setting Serial Comms on Propeller using Prop Basic..(Bean..?) — Parallax Forums

Help Please Setting Serial Comms on Propeller using Prop Basic..(Bean..?)

tsoliztsoliz Posts: 3
edited 2011-04-24 16:10 in Propeller 1
Been working with BST it is great work thanx to Bean and Jonnymac..!
I need to set the Serial Comms for 9600,7,E,2 on the Propeller chip...How can this be done..?
On the BS2 chip it is so easy just a line of code....Baud = 24660 .... = ' 9600,7,e,2 -Inverted
I have dug thru all the PropBasic posting's,Object downloads, Help files no luck.....just the default
8,n,1 did i miss something?My Hope is for a Prob Basic solution ie....(Bean or Jonnymac.lol)
Thanks in advance to anyone that can help...I am open to any solutions prop-basic,spin or assembly ...
Using the Basic Stamp 2 it looks like this..

SEROUT 1, 24660, [65] ' baudmode set for BS2 9600,7,E,2 Inverted and transmit the A character

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-04-24 13:48
    On the Propeller, serial comms is done by a "library routine" (object). There are several objects provided with the Propeller Tool in a library directory which BST will use if configured for that. These include "Simple_Serial" and "FullDuplexSerial". There are several other serial objects available in the Propeller Object Exchange, each with some special feature. All of them require an initialization call where you specify the I/O pins to be used, the Baud, and some mode information. I don't think any of them directly support 7 bit even parity. That you have to do yourself by computing the character with even parity, then transmitting it using 8 bit no parity. You can check the parity yourself on reception the same way. To transmit, you'd use something like this and pass the result value to your transmit routine:
    PRI getEvenParity(char)
       char &= %01111111   ' Make sure only 7 bits
       result := char + char>>1 + char>>2 + char>>3   ' Sum the bits of the character
       result += char>>4 + char>>5 + char>>6
       result := (!result &1) << 7 + char   ' Compute even parity & combine with character
    

    In PropBasic, this is even easier because you can use in-line assembly language and the hardware will compute the parity for you. If the character is stored in a cog location called "foobah", the following will add even parity:
    andn    foobah,#%01111111   wc
         muxnc   foobah,#%10000000
    
  • tsoliztsoliz Posts: 3
    edited 2011-04-24 16:10
    Hello Mike...Thank you for the quick response. Since i am using Prop Basic i entered a small program to send an "A" out the serial port and confirmed it works.. code below. Then i compiled to spin thru Bst and generated what looks like spin assembly.. code attached. Now i am in the process of trying to modify the assembly code to make the data sent with parity (7,E,2).So far my changes are having no effect on the output (remains 8,N,1). Maybe you can look at my assembly code (attached) and advise me. Nothing about making code work is easy so i really appreciate the time you take to look at mine..!

    Prop Basic CODE:

    DEVICE P8X32A, XTAL1, PLL16X
    FREQ 80_000_000
    BAUD CON "T9600"
    TX PIN 30 HIGH ' Send data back to PC on pin 30

    foobah DATA "A",13,10,0
    PROGRAM Start
    Start:
    SEROUT TX, BAUD, foobah ' Send A out pin 30
    PAUSE 3000
    RETURN
Sign In or Register to comment.