VMUSIC2 RTS/CTS flow control using pcFullDuplexSerial4FC
Ron Czapala
Posts: 2,418
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:
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
\>
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 - - - - - - - - - - - - - - - - - - │ │ │ │ The VNC1L-1A chip is a 3V3 │ │ device and its pins can be │ Jumpered │ directly connected to the │ to UART mode │ pins of the Propeller. The │ ┌───┬──────┐ │ inputs of VNC1L-1A are 5V │ │ │ │ │ tolerant, anyway. No need │ └───┴──────┘ │ for serial resistors. │ │ │ 1 2 3 4 5 6 8 │ │ VSS RTS VDD RXD TXD CTS RI │ └───┬───┬───┬───┬───┬───┬───┬───┘ │  │    GND ───────────┘ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 5V ───────────────┼───┘ │ │ │ P8X32A (Reg) │ │ │ │ ┌────────┬────────┐ │ │ │ └───────RTS─┤P0 |1 40|P31├ │ │ └────────────RX─┤P1 |2 39|P30├ │ └────────────────TX─┤P2 |3 38|P29├ └───────────────────────CTS─┤P3 |4 37|P28├ ┤P4 |5 36|P27├ ┤P5 |6 35|P26├ 3V3 ┤P6 |7 34|P25├ (Reg) ┤P7 |8 33|P24├ │ ┤VSS|9 32|VDD├───┘ ┤BOE|10 31| XO├ ┤RES|11 30| XI├ ┤VDD|11 29|VSS├───┐ ┤P8 |13 28|P23├ │ ┤P9 |14 27|P22├  ┤P10|15 26|P21├ GND ┤P11|16 25|P20├ ┤P12|17 24|P19├ ┤P13|18 23|P18├ ┤P14|19 22|P17├ ┤P15|20 21|P16├ └─────────────────┘ } 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
I made this change to my program and it is now working!!
I assume Tim will update the OBEX object.
You can see the serial output from revised program...
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.
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?
Tim indicated that it was changed in his version - I don't know if he plans to update OBEX...