Hi,
I'm having problems with making my Vmusic2 module play. I have connected it up in the SPI mode with the following pins connected to the picaxe 18x:
Vmusic2 pin 1 - Ground
Vmusic2 pin 2 - output 7 on picaxe
Vmusic2 pin 3 - 5V
Vmusic2 pin 4 - input 7 on picaxe
Vmusic2 pin 5 - output 6 on picaxe
Vmusic2 pin 6 - output 5 on picaxe
Vmusic2 pin 7 - not connected
I have the jumper bridging from uart/spi to the ground on the Vmusic2 module. My track on the USB stick is named '1.mp3'. I am running the code example above:
Symbol X = B6
Symbol N = B7
Symbol D = B8
Symbol SPI_RW = Bit0 '0 = Write, 1 = Read
Symbol SPI_OK = Bit1 '0 = Success, 1 = Failure
Symbol SPI_Read = 1
Symbol SPI_Write = 0
Symbol SPI_CS = Output5
Symbol SPI_CLK = Output6 ' The VMUSIC clock is active low, not active high as in the manual
Symbol SPI_DO = Output7
Symbol SPI_DI = Input7
MAIN:
Pause 1000
sertxd("Starting",CR,LF) ' Show status via debug terminal
low SPI_CS
gosub SPI_WaitForPrompt ' wait for VMUSIC2 Prompt on the SPI bus (">", CR) after initialisation
sertxd("Disk found",CR,LF) ' Show status via debug terminal
d = $91 ' IPH ' VMUSIC2 Short Command for hex input / output
gosub SPI_SendCmdCR
gosub SPI_EmptyRX ' Empty RX Buffer
d = $10 ' SCS ' VMUSIC2 Short Command for "Short Command Mode"
gosub SPI_SendCmdCR
gosub SPI_EmptyRX
gosub vm2_Playmp3 ' Play a tune
end
vm2_Playmp3:
d = $1D ' VMUSIC2 Short command for Play Music File
gosub SPI_SendCmd
d = $20
gosub SPI_SendCmd
d = "1"
gosub SPI_SendCmd
d = "."
gosub SPI_SendCmd
d = "m"
gosub SPI_SendCmd
d = "p"
gosub SPI_SendCmd
d = "3"
gosub SPI_SendCmd
d = CR
gosub SPI_SendCmd
gosub SPI_EmptyRX
return
SPI_SendCmdCR: ' SPI Send the byte in "D" to the SPI bus then send a "CR" to the bus
gosub SPI_SendCmd
D = CR
gosub SPI_SendCmd
return
SPI_SendCmd: ' SPI Send the byte in "D" until a "Status OK" is seen
SPI_RW = SPI_Write
do
gosub SPI_GO
loop until SPI_OK = 0
return
SPI_EmptyRX: ' Read the SPI buffer until status bit is 1 to clear it
SPI_RW = SPI_Read
do
gosub SPI_GO
loop until SPI_OK = 1
return
SPI_WaitForPrompt: ' subroutine which waits for the prompt from the VMUSIC2 (">", CR)
d = ">"
gosub SPI_WaitForD
d = CR
gosub SPI_WaitForD
return
SPI_WaitForD: ' Keep reading the SPI bus until the character in "D" is seen
SPI_RW = SPI_Read
do
do
gosub SPI_GO
loop until SPI_OK = 0
loop until X = D
return
SPI_GO: ' bitbang the VMUSIC2 SPI bus
' Entry - D = Byte to write to SPI bus, SPI_RW = either SPI_Write or SPI_Read
' Exit = X = Byte Read from SPI bus, SPI_OK = either 0 or 1 depending on success status
if SPI_RW = SPI_Write then
X = D
end if
low SPI_CS
high SPI_CS
high SPI_DO ' SPI Start bit
low SPI_CLK
high SPI_CLK
if SPI_RW = SPI_WRITE then
low SPI_DO ' SPI Read Status Bit
else
high SPI_DO ' SPI Write Status Bit
end if
low SPI_CLK
high SPI_CLK
low SPI_DO ' SPI "ADD" 0 = data 1 = REGISTER
low SPI_CLK
high SPI_CLK
gosub SPI_IO
low SPI_CLK
SPI_OK = SPI_DI ' Success?
high SPI_CLK
low SPI_CS
low SPI_DO
return
SPI_IO: ' 8 bit bitbang routine
for N = 0 to 7
if X > 127 Then SPI_IO_1
low SPI_DO
goto SPI_IO_0
SPI_IO_1:
high SPI_DO
SPI_IO_0:
low SPI_CLK
X = X * 2 + SPI_DI ' shift X left and add input bit to X
high SPI_CLK
next
return
----------------------------------------
The program downloads fine, and the Vmusic2 module seems to turn on as the red LED turns on and the usb stick flashes but the track does not play. Has anyone got any ideas, am I missing anything out?
Or does anyone have sample code for running the Vmusic2 in UART mode?