Shop OBEX P1 Docs P2 Docs Learn Events
Question about pin assignment — Parallax Forums

Question about pin assignment

Don MDon M Posts: 1,652
edited 2012-10-27 20:26 in Propeller 1
For example let's say I have PST (or any serial terminal program for that matter) connected to P30 & P31 using fullduplexserial.spin and I have a WiFi module's uart pins connected to P20 & P21. I would have a menu system in my spin code to perform various functions through P30 & P31 with PST.

Now let's say that one of the menu selections might be to configure the WiFi module through it's uart connection using PST. Assuming that P30 & P20 are RX and P31 & P21 are TX respectively could I do something like:
  if (some selection is made to program WiFi)
    ina[20] := ina[30]
    outa[21] := outa[31]


to temporarily re-assign the flow of serial commands?

If it can be done would the baud rate follow through to the new pins and how would I un-assign these (turn that feature off)? Can I do this without launching another instance of fullduplexserial.spin?

Or is there a better way of doing this? Maybe this is a dumb suggestion I don't know......

Thanks.
Don

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2012-10-27 20:22
    It's not as simple as that. What you need is the equivalent of:
    repeat while connected
        outa[to_pst]  := ina[from_wifi]
        outa[to_wifi] := ina[from_pst]
    
    Main issue here is speed (it's SPIN after all) but it may just be fast enough. You could also do this in PASM at the cost of a cog or even utilise counters. Just see how far you get with the example above. Then we can go from there.
  • msrobotsmsrobots Posts: 3,709
    edited 2012-10-27 20:26
    Don,

    you can not do it like you wrote. Pin-redirection is a feature that will be included in P2 (group-wise) but is not there in P1

    But you can Start a second Fullduplexserial on P20/21 and then read one and write to the other in a loop.

    Both Fullduplexserial can have different BaudRates als lon gas your buffers are big enought.

    so FDS1 talking to PST and FDS2 talking to you WIFI module.

    then you can do something like this
       ...
       key:=-1
       exitvar:=false
       repeat 
          key:=FDS1.rxcheck  ' check PST ... rxcheck returns -1 if no key there else ascii code of key
          if key>-1
             if key==27
               exitvar:= true       ' exit loop if esc-key is pressed in PST
             else
               FDS2.tx(key)      ' send key/char to WIFI
          key:=FDS2.rxcheck ' check WIFI ... see above
          if key>-1
             FDS1.tx(key)        ' send key/char to PST
      until exitvar
         
    

    Enjoy!

    Mike
Sign In or Register to comment.