Shop OBEX P1 Docs P2 Docs Learn Events
Help with FullDuplexSerial4portPlus_0v3 — Parallax Forums

Help with FullDuplexSerial4portPlus_0v3

Mike GMike G Posts: 2,702
edited 2012-03-18 12:30 in Propeller 1
I'm having trouble getting the the FullDuplexSerial4portPlus_0v3 object to function as expected. I'm simply trying to echo the the Rx bytes to the PST. FullDuplexSerial work exactly as I expect, each byte is echoed to PST. The 4 port FullDuplexSerial4portPlus_0v3 object sends the same char (*) over and over again. The input device is a bar code reader. The expected receive packet is *1234*<cr><lf>. I'm guessing it might be the 6.25 MHz crystal which is messing up the bit timing, or I don't understand how to instantiate the 4 port driver, or I have a bug.

The idea is to use two barcode readers on either side of a Propeller powered POS terminal. I have two instances of FullDuplexSerial working great but I'd like to free up a COG. I'll take a few minutes to see if this is related to bit_ticks.

Does anyone see something obvious I'm missing?

Here's two commented unit test versions.
CON

  _clkmode      = xtal1 + pll16x
  '_xinfreq      = 6_250_000
  _xinfreq       = 5_000_000
  

  PAD_RX        = 16
  PAD_TX        = 17
  ID_LEN        = 17
  LEFT_PORT     = 3

VAR
  byte  id[ID_LEN]
  byte  port

DAT
  lineBreak   byte  $13, $10, $0
  

OBJ
  pad    : "FullDuplexSerial4portPlus_0v3" 
  'pad    : "FullDuplexSerial" 
  pst    : "Parallax Serial Terminal"  


PUB Main  | char, frame, i, flag
  pst.start(115200)
  
  'pad.start(PAD_RX, PAD_TX, %0000, 115200)
  
  pad.AddPort(LEFT_PORT, PAD_RX, PAD_TX, {
  } pad#PINNOTUSED, pad#PINNOTUSED, pad#DEFAULTTHRESHOLD, pad#NOMODE, pad#BAUD115200)
  pad.Start
  
  pause(1000)

  pst.str(string("Pad Debugger",13))

  char := 0
  frame := 0
  i := 0

  repeat
    'char := pad.rx
    char := pad.rx(LEFT_PORT)
    pst.char(char)
    pause(20) 



  
PRI Pause(Duration)  
  waitcnt(((clkfreq / 1_000 * Duration - 3932) #> 381) + cnt)
  return

  
PUB IsIdDelimiter(value)
'                         #    *    +     
  return lookdown(value: $23, $2A, $2B

Comments

  • Tracy AllenTracy Allen Posts: 6,664
    edited 2012-03-18 12:17
    Hi Mike,
    It needs
    pad.init
    
    first of all, before any of the addports. Without that, there are zero buffers!

    I've made several subsequent changes, including one that forces the buffers to default values if it happens that init is not called. Init also stops the cog if it had already been running, but that is not an issue in your test program.

    The 0v3 version as posted has rather unconventional buffer sizes, as a demo. You might want to change those.
    [FONT=courier new][SIZE=1]' [COLOR=#020FC0]Choose better sizes![/COLOR]
      TX_SIZE0                      = 16  ' enter in the needed size in bytes for each rx and tx buffer
      TX_SIZE1                      = 1   ' these values are arbitrary, just to show that they can be different
      TX_SIZE2                      = 16  ' not necessarily binary or less than any particular limit.
      TX_SIZE3                      = 64   '
    
      RX_SIZE0                      = 8
      RX_SIZE1                      = 1
      RX_SIZE2                      = 600
      RX_SIZE3                      = 64[/SIZE][/FONT]
    

    I had added code to suppress framing errors, but in 0v3 that is implemented on only ports 0 and 1, not on port 3 that you used. So, if that port input pin is floating and low, it might pick up a lot of ascii nulls. When I put it in OBEX, all ports will suppress framing errors.

    I just noticed that the DEFAULTTHRESHOLD constant got lost from the program. I will restore that. You are not using rx flow control, so it does not matter. BST flags that as an error when it is referenced but does not exist.
  • Mike GMike G Posts: 2,702
    edited 2012-03-18 12:30
    Thanks Tracy Allen!

    I'll wire up a new unit test with updated buffers.

    EDIT: Works perfectly now with the pad.init and updated buffers
    CON
    
      _clkmode      = xtal1 + pll16x
      _xinfreq      = 6_250_000
      '_xinfreq       = 5_000_000
      
    
      PAD_RX        = 16
      PAD_TX        = 17
      ID_LEN        = 17
      LEFT_PORT     = 3
    
    VAR
      byte  id[ID_LEN]
      byte  port
    
    DAT
      lineBreak   byte  $13, $10, $0
      tempstr     byte  $0[12]
      
    
    OBJ
      pad    : "FullDuplexSerial4portPlus_0v3" 
      'pad    : "FullDuplexSerial" 
      pst    : "Parallax Serial Terminal"  
    
    
    PUB Main  | char, frame, i, flag
      pst.start(115200)
      
      'pad.start(PAD_RX, PAD_TX, %0000, 115200)
    
      pad.init
      pad.AddPort(LEFT_PORT, PAD_RX, PAD_TX, {
      } pad#PINNOTUSED, pad#PINNOTUSED, pad#DEFAULTTHRESHOLD, pad#NOMODE, pad#BAUD115200)
      pad.Start
      
      pause(1000)
    
      pst.str(string("Pad Debugger",13))
    
      char := 0
      frame := 0
      i := 0
    
      repeat
        'char := pad.rx
        char := pad.rx(LEFT_PORT)
        pst.char(char)
        pause(20) 
    
    
      
    PRI Pause(Duration)  
      waitcnt(((clkfreq / 1_000 * Duration - 3932) #> 381) + cnt)
      return
    
      
    PUB IsIdDelimiter(value)
    '                         #    *    +     
      return lookdown(value: $23, $2A, $2B)
    
Sign In or Register to comment.