Shop OBEX P1 Docs P2 Docs Learn Events
VMUSIC2 RTS/CTS flow control using pcFullDuplexSerial4FC — Parallax Forums

VMUSIC2 RTS/CTS flow control using pcFullDuplexSerial4FC

Ron CzapalaRon Czapala Posts: 2,418
edited 2011-10-08 18:55 in Propeller 1
I had no problem setting up a VMUSIC2 with a BS2 using hardware flow control, but I am having a difficult time getting it to work with a Propeller.

The BS2 code displays the mp3's ID3TAG info (song title, etc) and time status info properly.

I am using Tim Moore's four port serial object.

The program reads and displays the initialization info in the Parallax Serial Terminal, but does not respond to commands to set the monitor mode, play commands, etc.

Does anyone have any suggestions or code examples using flow control with this object?


Thanks,
- Ron

Output:
Please wait

Ver 03.68VMSC1F On-Line:
Device Detected P2
No Upgrade
D:\>
IPA mode
Extended cmds
Random play
CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000
  vm_rx  = 1             ' Receive Data    <-- VMusic2 pin 5  (TXD)   - yellow
  vm_tx  = 2             ' Transmit Data   --> VMusic2 pin 4  (RXD)   - orange
  vm_cts = 3             ' Clear To Send   <-- VMusic2 pin 2  (RTS#)  - brown
  vm_rts = 0             ' Request To Send --> VMusic2 pin 6  (CTS#)  - green 
  vm_port = 0
  vol = 0                '0=max 254=min
  BAUD   = 9_600
{
-------------------------------Schematics---------------------------------
 
                 VMUSIC2 MP3 module
           - - - - - - - - - - - - - - - - - -        
            &#9474;                               &#9474;
            &#9474;                               &#9474; The VNC1L-1A chip is a 3V3 
            &#9474;                               &#9474; device and its pins can be
            &#9474;              Jumpered         &#9474; directly connected to the                                   
            &#9474;            to UART mode       &#9474; pins of the Propeller. The                               
            &#9474;            &#9484;&#9472;&#9472;&#9472;&#9516;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;       &#9474; inputs of VNC1L-1A are 5V                                 
            &#9474;            &#9474; • &#9474;      &#9474;       &#9474; tolerant, anyway. No need                     
            &#9474;            &#9492;&#9472;&#9472;&#9472;&#9524;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496;       &#9474; for serial resistors.
            &#9474;                               &#9474;
            &#9474;   1   2   3   4   5   6   8   &#9474;                          
            &#9474;  VSS RTS VDD RXD TXD CTS  RI  &#9474;                        
            &#9492;&#9472;&#9472;&#9472;&#9516;&#9472;&#9472;&#9472;&#9516;&#9472;&#9472;&#9472;&#9516;&#9472;&#9472;&#9472;&#9516;&#9472;&#9472;&#9472;&#9516;&#9472;&#9472;&#9472;&#9516;&#9472;&#9472;&#9472;&#9516;&#9472;&#9472;&#9472;&#9496;                             
                &#9474;   &#61602;   &#9474;   &#61600;   &#61602;   &#61600;                          
 GND &#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496;   &#9474;   &#9474;   &#9474;   &#9474;   &#9474;    
                    &#9474;   &#9474;   &#9474;   &#9474;   &#9474;                    
                    &#9474;   &#9474;   &#9474;   &#9474;   &#9474;           
  5V &#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9532;&#9472;&#9472;&#9472;&#9496;   &#9474;   &#9474;   &#9474;                   P8X32A
(Reg)               &#9474;       &#9474;   &#9474;   &#9474;            &#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9516;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;                        
                    &#9474;       &#9474;   &#9474;   &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;RTS&#9472;&#61626;&#9508;P0 |1      40|P31&#9500;                              
                    &#9474;       &#9474;   &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;RX&#9472;&#61627;&#9508;P1 |2      39|P30&#9500;                              
                    &#9474;       &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;TX&#9472;&#61626;&#9508;P2 |3      38|P29&#9500;                                         
                    &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;CTS&#9472;&#61627;&#9508;P3 |4      37|P28&#9500;                              
                                                 &#9508;P4 |5      36|P27&#9500;                                                          
                                                 &#9508;P5 |6      35|P26&#9500;  3V3                                     
                                                 &#9508;P6 |7      34|P25&#9500; (Reg)                                   
                                                 &#9508;P7 |8      33|P24&#9500;   &#9474;                        
                                                 &#9508;VSS|9      32|VDD&#9500;&#9472;&#9472;&#9472;&#9496;
                                                 &#9508;BOE|10     31| XO&#9500;
                                                 &#9508;RES|11     30| XI&#9500;        
                                                 &#9508;VDD|11     29|VSS&#9500;&#9472;&#9472;&#9472;&#9488;           
                                                 &#9508;P8 |13     28|P23&#9500;   &#9474;          
                                                 &#9508;P9 |14     27|P22&#9500;   &#61464;                                            
                                                 &#9508;P10|15     26|P21&#9500;  GND          
                                                 &#9508;P11|16     25|P20&#9500;               
                                                 &#9508;P12|17     24|P19&#9500; 
                                                 &#9508;P13|18     23|P18&#9500; 
                                                 &#9508;P14|19     22|P17&#9500; 
                                                 &#9508;P15|20     21|P16&#9500; 
                                                 &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496;
}  
VAR
  long useser           'USB serial connection detected T/F
 
OBJ
  uarts         : "pcFullDuplexSerial4FC" '1 COG for 4 serial ports    
  Debug         : "FullDuplexSerial"  '"SerialMirror"  '"Extended_FDSerial"
 
PUB Main       
'  dira[vm_tx]~~                    'output
  dira[vm_rts]~~
'  outa[vm_tx]~~                     ' Initialize Transmit Line - set high
  outa[vm_rts]~                     ' Take Vinculum Out Of Reset - set low
' waitcnt(clkfreq*2 + cnt)
 
  useser := false
  if ina[31] == 1                      ' RX (pin 31) is high if USB is connected
    Debug.start(31, 30, 0, 57600)      ' ignore tx echo on rx
'   waitcnt(clkfreq * 3 + cnt)         ' Pause for FullDuplexSerial.spin to initialize
    useser := true                     ' Debug serial connection is active 
  if useser == true
    Debug.tx(16)  'cls
    Debug.str(string("Please wait",13))
 
  uarts.Init
  uarts.AddPort(vm_port,vm_rx,vm_tx,vm_cts,vm_rts,UARTS#DEFAULTTHRESHOLD,UARTS#NOMODE,UARTS#BAUD9600)
'  uarts.AddPort(vm_port,vm_rx,vm_tx,UARTS#PINNOTUSED,vm_rts,UARTS#DEFAULTTHRESHOLD,UARTS#NOMODE,UARTS#BAUD9600)
'  uarts.AddPort(vm_port,vm_rx,vm_tx,vm_cts,vm_rts,4,UARTS#NOMODE,UARTS#BAUD9600)
  uarts.Start    
  waitcnt(clkfreq * 2 + cnt)
  Read_VM
  waitcnt(clkfreq * 2 + cnt)
 
  if useser == true
    Debug.str(string("IPA mode",13))
  uarts.str(vm_port, string("IPA",$0D)) 'monitor mode ascii
  Read_VM
  waitcnt(clkfreq / 2 + cnt)   
 
  if useser == true
    Debug.str(string("Extended cmds",13)) 
  uarts.str(vm_port, string("ECS",$0D))      'extended command set
  Read_VM
  waitcnt(clkfreq / 2 + cnt)   
 
' uarts.str(vm_port, string("VSV "))
' uarts.dec(vm_port,vol)                 'set volume min
' uarts.tx(vm_port,$0D)
' Read_VM
' waitcnt(clkfreq / 2 + cnt)   
 
' if useser == true   
'   debug.str(string("Firmware version: ",13))
' uarts.str(vm_port, string("FWV",$0D))
' Read_VM
 
  if useser == true
    Debug.str(string("Random play",13))
  uarts.str(vm_port, string("VRR",$0D))   'all random
  repeat
    Read_VM
    waitcnt(clkfreq / 10 + cnt)   
 
PUB Read_VM | iobyte
  iobyte:=0
  repeat
    iobyte:=uarts.rxtime(vm_port,500)
    if iobyte < 0 
      quit
    else
      if useser == true   
        debug.tx(iobyte)

Comments

  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-10-08 09:41
    Here is the output from the BS2 version:
    Ver 03.68VMSC1F On-Line:
    Device Detected P2
    No Upgrade
    D:\>
    D:\>
    D:\>
    D:\>
    Firmware version:
    MAIN 03.68VMSC1F
    RPRG 1.00R
    D:\>
    Playing YOU'LL~1.MP3
    01
    You'll Never Find Another Love Like Mine
    Lou Rawls
    Greatest Hits [Cema]
    T $00 $00
    T $01 $00
    T $02 $00
    T $03 $00
    T $04 $00
    T $05 $00
    T $06 $00
    T $07 $00
    T $08 $00
    T $09 $00
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-10-08 12:12
    I've been chatting with Tim Moore and it seems he made a change to his object on 08/14/08 that was not uploaded to OBEX:
    Looking at my version I had a bug fix a while ago for flow control

    ''* 8/14/08: CTS/RTS inverted by default, forgot that RS232 level *
    ''* shifters invert, so changed the default invert logic *

    do you have the same comment at the start of the file?

    Tim

    I made this change to my program and it is now working!!

    I assume Tim will update the OBEX object.
      uarts.AddPort(vm_port,vm_rx,vm_tx,vm_cts,vm_rts,UARTS#DEFAULTTHRESHOLD,[COLOR=red]UARTS#INVERTCTS[/COLOR],UARTS#BAUD9600) 
    

    You can see the serial output from revised program...
    Please wait
    Ver 03.68VMSC1F On-Line:
    Device Detected P2
    No Upgrade
    D:\>
    IPA mode
    D:\>
    Extended cmds
    D:\>
    D:\>
    Firmware version:
    MAIN 03.68VMSC1F
    RPRG 1.00R
    D:\>
    Random play
    Playing BREEZIN'.MP3
    01
    Breezin'
    George Benson
    Breezin'
    T $00 $00
    T $01 $00
    T $02 $00
    T $03 $00
    ...
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2011-10-08 13:18
    Thanks for pointing that out Ron. The current OBEX version 1.1 has comments that go up to 7/24/08, not 8/14/08.

    I suggest that you put that information in a review attached to the OBEX listing so if Tim can't get around to it, the info will be there for people to see.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-10-08 13:35
    Thanks for pointing that out Tim. The current OBEX version 1.1 has comments that go up to 7/24/08, not 8/14/08.

    I suggest that you put that information in a review attached to the OBEX listing so if Tim can't get around to it, the info will be there for people to see.

    I sent Tim a couple of PMs earlier today so I expect he will update OBEX. I also informed Duane Degn since he has various modified versions of Tim's code which he may want to revise when Tim posts his update.

    Tim's object is great! This is the first time I have used it.

    To really utilize the VMusic2 I think you need a serial driver which supports hardware flow control.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2011-10-08 13:42
    I agree, it is a real workhorse. Thanks, Tim!
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-10-08 18:25
    I created another thread in the Projects forum showing a remote controlled VMUSIC2 player I made after getting this resolved...
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2011-10-08 18:31
    Ron,

    I'm not sure it needs an update in the OBEX code. Changing the code could disrupt systems that are already working. It is more a matter of an explanation to say how it does work. As you have shown, it can work fine if you choose the proper mode parameter. (Nice work! I don't have one of the vMusic, but I've used the vDrive on the Stamp but not yet on the Prop.)

    For the record:
    RS232 levels are can be confusing, but the standard is that flow control works as follows:

    Noninverted logic (which is the usual mode at the pins of a microcontroller)
    --Stop bits and mark bits are a high level, and the start bit and space bits are low
    --Flow control has the same sense, High=Stop=do not send/receive data. Low=Start=send data, ready to receive.

    Inverted logic (usual on external RS232 lines through an inverting driver)
    Opposite of above.
    --Stop bits and mark bits are a low or negative level, and start bits and space bits are high.
    --Flow control, same sense, Stop=low=do not send/receive data. Go=Start=high=send data, ready to receive.

    In either case, inverting or not, mark bits are logical 1, and space bits are logical 0.

    In PCfullDuplexSerial4FC as it stands now, logical a mode of %000000 (uarts#nomode) specifies non-inverted rx and tx, so the start bit is low and stop bits are high. But if that is combined with cts and rts pins, then transmit/receive will occur only when the respective cts and rts pins are high. That is the opposite of the standard, where the enabling state would be low. So that is why you would have to choose the %110000 mode to invert the sense of cts and rts to make it operate in the standard manner. Similarly, if you are using inverted logic for rx and tx, the standard mode parameter would then be %000011. If the code changes, then the standard choices would become %00000 or %110011, but again, I would hesitate to change it at this point in time.

    I don't know, Ron, did Tim say he was actually planning to change the sense of it in the code, or just leave it with an explanation?
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-10-08 18:55
    Ron,

    I'm not sure it needs an update in the OBEX code. Changing the code could disrupt systems that are already working. It is more a matter of an explanation to say how it does work. As you have shown, it can work fine if you choose the proper mode parameter. (Nice work! I don't have one of the vMusic, but I've used the vDrive on the Stamp but not yet on the Prop.)

    ...

    I don't know, Ron, did Tim say he was actually planning to change the sense of it in the code, or just leave it with an explanation?

    Tim indicated that it was changed in his version - I don't know if he plans to update OBEX...
    Looking at my version I had a bug fix a while ago for flow control

    ''* 8/14/08: CTS/RTS inverted by default, forgot that RS232 level *
    ''* shifters invert, so changed the default invert logic *

    do you have the same comment at the start of the file?

    Tim
Sign In or Register to comment.